Mani
Mani

Reputation: 2563

AND not working with other query fields in Loopback

I'm new in Loopback so may be it sound silly. Here is my query

const treats = await treatDetails.find({
  where: {
    and: someArray,
    endDate: { gt: someDate },
  },

someArray is an array on which i want to apply AND operation and outside of that and i want to get records with endDate greater than someDate

Upvotes: 1

Views: 46

Answers (1)

IftekharDani
IftekharDani

Reputation: 3729

You can use and with array of json object.

Also you can add endDate: { gt: someDate } in and

let cond = [{ id: "id" }, { 'image': "url" }];

cons.push({ endDate: { gt: someDate } });

Model.find({ where: { and: cond } });

Upvotes: 3

Related Questions