Ad

DynamoDB Get Item But Only If An Attribute In That Item Is False

- 1 answer

So I have a an item I only want to get if its not set to be deleted.

Is it more efficient to sort it away in Node after I have fetched it? I cannot find any conditions in the documentation in the get call to dynamodb. How do I approach this scenario?

Ad

Answer

You can set in params isDeleted:false. Doing so you can filter by any attribute you want, not only by isDeleted. See the example:

 var AWS = require("aws-sdk");

 AWS.config.update({
   region: "us-west-2",
   endpoint: "http://localhost:8000"
 });

 var docClient = new AWS.DynamoDB.DocumentClient();


 var params = {
     isDeleted : false
 };

 docClient.query(params, function(err, data) {
     if (err) {
         console.error("Unable to query. Error:", JSON.stringify(err, null, 2));
     } else {
         console.log("Query succeeded.");
     }
 });

Is that what you're looking for?

Ad
source: stackoverflow.com
Ad