Example #1
0
        public async Task <UserModel> GetUserById(UserId userId)
        {
            var request = new QueryRequest(tableName);

            request.IndexName     = "GSI1";
            request.KeyConditions = new Dictionary <string, Condition>
            {
                { "SortKey", dynamoDbCore.GetStringEqualsCondition("user") },
                { "GSI1PartitionKey", dynamoDbCore.GetStringEqualsCondition(userId.ToDbValue()) }
            };

            return((await dynamoDbCore.Query(request, Mappers.UserModel)).FirstOrDefault() ?? UserModel.Null);
        }
Example #2
0
        public Task <IEnumerable <PhotoComment> > GetComments(PhotoId photoId)
        {
            logWriter.LogInformation($"{nameof(GetComments)}({nameof(photoId)} = '{photoId}')");
            QueryRequest request = new QueryRequest
            {
                TableName     = tableName,
                KeyConditions = new Dictionary <string, Condition>
                {
                    { FieldMappings.PartitionKey, dynamoDbCore.GetStringEqualsCondition(photoId.ToDbValue()) },
                    { FieldMappings.SortKey, dynamoDbCore.GetStringBeginsWithCondition("comment") }
                }
            };

            return(dynamoDbCore.Query(request, Mappers.PhotoComment));
        }