我对dynamodb很新,我在这里遇到了一些情况。我正在处理一个已在此处可用的代码。我的要求是我想更改我的查询以添加过滤器。
我目前的代码是
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},
我想检查城市中是否有特定值,我浏览并发现CONTAINS参数将是合适的。但不知道在哪里添加
假设我想检查城市是否包含值“LOS ANGELES”,其中代码应放在上面的代码中。
会是这样吗
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},
由于
答案 0 :(得分:3)
我自己得到了,我必须像这样改变我的查询
reqObj.FilterExpression = "isActive = :isActive AND isDeleted = :isDeleted AND CONTAINS(city, :city) AND #state = :stateName",
contains,是一个函数,它将包含值列表,其中包含键值
由于