简体   繁体   中英

How can i call query with parameter and then populate using dynamoose

 var added = await Feature.scan("parentId").eq(baseIds).exec()
        .then(function (add) {
            return add.populate({
               path: 'parentId',
              model: 'Feature'
             })
           })

I have a server already setup working with dynamoose. I want to make a query on basic of a value field and then populate but i am not able to achieve it with the solutions in the dynamoose api docs.Please help here.

According to the Dynamoose documentation :

Dog.scan().exec()
  .then(function(dogs) {
    return Promise.all(dogs.map(function(dog) {
      return dog.populate({
        path: 'parent',
        model: 'Dog'
      });
    }));
  })
  .then(function(dogs) {
    console.log(dogs);
  });

Since scan gives you an array of objects, you have to populate each item individually and wait for all those promises to succeed.

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