Search code examples
javascriptnode.jsecmascript-6loopbackjsloopback

Not able to update model in loopback


I am using updatingAll method in loopback but it is not working I am not able to understand the reason

I have written something like this

let data = {
      isActive: false
    };

      myModel
          .updateAll(data, {
            id: {
              inq: questionIds
            },
          });

Solution

  • The order of parameters in updateAll seems to be incorrect. From documentation:

    PersistedModel.updateAll([where], data, callback)

    Also, it seems a callback function is required.

    Callback function called with (err, info) arguments. Required.

    So your call should look like this:

    let data = {
        isActive: false
    };
    myModel.updateAll({
        id: {
            inq: questionIds
        },
    }, data, (err, info) => null); //might want to add error checking to callback function