dynamodb-queries

DynamoDb: Query items between two dates

帅比萌擦擦* 提交于 2020-04-16 03:48:08
问题 I'm not having much luck with this query, it returns 0 items const { Items } = await this.dynamoDb.query({ TableName: 'exampleTableName', IndexName: 'createdDateTime-index', KeyConditionExpression: '#createdDateTime BETWEEN :fromDateTime AND :toDateTime AND #status = :status', ExpressionAttributeNames: { '#status': 'status', '#createdDateTime': 'createdDateTime', }, ExpressionAttributeValues: { ':fromDateTime': '2017-02-20T01:58:49.710Z', ':toDateTime': new Date().toISOString(), ':status':

DynamoDB,how to query with BEGINS_WITH

痴心易碎 提交于 2020-02-25 00:56:35
问题 i'm using DocumentClient for query. and using serverless framework with DynamoDb. i'm trying to query with BEGINS_WITH without providing any primary key. here is how my data looks like: [ { id: 1, some_string: "77281829121" }, { id: 2, some_string: "7712162hgvh" }, { id: 3, some_string: "7212121" } ] here is my serverless.yml [i.e Table config i guess]: Resources: IPRecord: Type: 'AWS::DynamoDB::Table' Properties: TableName: ${file(./serverless.js):Tables.IPRecord.name} BillingMode: PAY_PER

DynamoDB,how to query with BEGINS_WITH

陌路散爱 提交于 2020-02-25 00:55:31
问题 i'm using DocumentClient for query. and using serverless framework with DynamoDb. i'm trying to query with BEGINS_WITH without providing any primary key. here is how my data looks like: [ { id: 1, some_string: "77281829121" }, { id: 2, some_string: "7712162hgvh" }, { id: 3, some_string: "7212121" } ] here is my serverless.yml [i.e Table config i guess]: Resources: IPRecord: Type: 'AWS::DynamoDB::Table' Properties: TableName: ${file(./serverless.js):Tables.IPRecord.name} BillingMode: PAY_PER

How can I dynamically substitute where condition parameters in Dynamodb?

别说谁变了你拦得住时间么 提交于 2020-01-25 06:55:44
问题 Current code Example: Scan * from table_name where name='ajith' and lastname='gupta'; In the real scenario, I will be getting different values. I need to pass those here in this above query and get the output. Also, it's better to prevent data injection. Desired: Scan * from table_name where name=? and lastname=?; 回答1: Use the Expression Attribute Names and Expression Attribute Values parameters. Javascript example using the DocumentClient: let params = { TableName: 'table_name',

dynamoDB: How to query N elements starting at X index

自古美人都是妖i 提交于 2020-01-16 09:11:07
问题 I'm looking for examples of the code using python3, no links to the documentation. I havent found examples in the documentation. I'm looking to query 2 elements with the category "red" starting at the ID 1. This is my table: | ID | category | description | | 0 | red | .... | | 1 | red | .... | | 2 | blue | .... | | 3 | red | .... | | 4 | red | .... | The query should return the elements with the id 1 and 3. Looking forward to read your examples. Thanks in advance. 回答1: In dynamo Db you query

Is there any way we can restrict the length of Auto generated hashKey in DynamoDb

删除回忆录丶 提交于 2020-01-16 08:46:30
问题 I have the below code (Java Entity class)and upon executing my java code I am able to auto-generate the unique hashkey value for my column id/myId. Which look like this " 88a2795a-3836-4720-926a-517506b18469 ". My question: Is there any way we can restrict the length of Auto generated hashKey in DynamoDb or we can formate it. import com.amazonaws.services.dynamodbv2.datamodeling.*; import org.springframework.data.annotation.Id; @DynamoDBTable(tableName = "test_app") public class MyApplication

How to filter by elements in an array (or nested object) in DynamoDB

拈花ヽ惹草 提交于 2020-01-15 12:09:51
问题 My data is as follows: [ { orgId: "ABC", categories: [ "music", "dance" ] }, { orgId: "XYZ", categories: [ "math", "science", "art" ] }, ... ] I have the primary key on orgId , and I want to use DynamoDB query to filter and return only items with category "science," for example. (Category does not need to be part of any index: I am willing to accept the additional worker overhead, provided that I can do the query within Dynamo itself.) I am having a dickens of a time getting this working. I

How to filter by elements in an array (or nested object) in DynamoDB

眉间皱痕 提交于 2020-01-15 12:08:27
问题 My data is as follows: [ { orgId: "ABC", categories: [ "music", "dance" ] }, { orgId: "XYZ", categories: [ "math", "science", "art" ] }, ... ] I have the primary key on orgId , and I want to use DynamoDB query to filter and return only items with category "science," for example. (Category does not need to be part of any index: I am willing to accept the additional worker overhead, provided that I can do the query within Dynamo itself.) I am having a dickens of a time getting this working. I

Dynamo db pagination

孤街浪徒 提交于 2020-01-05 05:38:07
问题 I want to use pagination in dynamodb using aws-sdk DocumentClient() I am using node.js. What I want to do is get first 10 items and then return these value to the user. After that user makes a new request in which he tell the server to start from 10 and the server get other 10 from 10 to 20 and return the response back. I have tried the LastEvaluatedKey But my scenario is different. Is there any way that I can tell dynamodb to start from specific Item e.g 1 and then set Limit: 10 . 回答1: I