0

I have a structure that looks like this:

Model: {
  "name":"testing",
  "details":["detail1","detail2","detail10"]
}

How does one go about finding all instances where an above structure contains an instance of detail2 within their details property? I've tried:

Model.find({where:{details:{elemMatch:{"detail2"}}}},function(err,models){
    console.log(models);
    console.log(err);
});

and:

Model.find({details:"detail2"},function(err, models){
      //throws [Error: Items must be an array: "details2"]
});

1 Answer 1

1

From what I can see (based on this comment from engineering, https://github.com/strongloop/loopback-datasource-juggler/issues/342#issuecomment-73138705), it is not possible to filter like this. You would need to get the objects and post process. In theory you could build your own remote method and do the filtering on the server so you aren't doing it server-side.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.