简体   繁体   中英

dynamo Db contains

I am very new to dynamodb, i got stuck up with a situation here. I am working on a code which is already available here. My requirement is I want to change my query to add a filter.

My current code is

reqObj.TableName = config.storeTableName;
   reqObj.FilterExpression = "isActive = :isActive AND isDeleted = :isDeleted AND #state = :stateName",
   reqObj.ExpressionAttributeNames = {"#state": "state"};
   reqObj.ExpressionAttributeValues= {":isActive": true, ":isDeleted": false , ":city": cityName , ":stateName" : region_code},

I want to check whether a specific value is there in city, i browsed and found out CONTAINS parameter will be suitable. But don't know where to add

Suppose i want to check whether the city contains a value "LOS ANGELES", where the code should be placed in the above code.

will It Be like this

reqObj.TableName = config.storeTableName;
       reqObj.FilterExpression = "isActive = :isActive AND isDeleted = :isDeleted AND CONTAINS(city = :city) AND  #state = :stateName",
       reqObj.ExpressionAttributeNames = {"#state": "state"};
       reqObj.ExpressionAttributeValues= {":isActive": true, ":isDeleted": false , ":city": cityName , ":stateName" : region_code},

Thanks

I got it myself, I have to change my query like this

reqObj.FilterExpression = "isActive = :isActive AND isDeleted = :isDeleted AND CONTAINS(city, :city) AND  #state = :stateName",

contains, is a function which will have the list of values , with the key value along with it

Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM