Loopback: greater and less than where clause is not working togather

Created on 22 Oct 2016  路  8Comments  路  Source: strongloop/loopback

Hello,

I want to fetch datewise data but i am not getting desired output.
I am using this {"createdAt":{"gt":"2016-10-18","lt":"2016-10-21"}} in where clause to fetch data .. but it is giving all the records.
Individullay i am gtting correct response but when I am using gt and lt togheter it is giving all the data

Any help would be appreciable..

Please suggest.

triaging

Most helpful comment

@ruoru maybe in this way.

where: {
    createdAt: { between: ['2016-10-18', '2016-10-21'] }
}

All 8 comments

is this confirmed?
@shyam2k16 do you get the same result if you split the query object like {"createdAt":{"gt":"2016-10-18"}, "createdAt":{"lt":"2016-10-21"}} ?

@shyam2k16 @phra I think the right format is

where: {
  and: [
    {createdAt: {gt: '2016-10-18'}},
    {createdAt: {lt: '2016-10-21'}}
  ]
}

Please see our doc for where filter to know more about how to use and/or:
https://docs.strongloop.com/display/public/LB/Where+filter#Wherefilter-and/or

@jannyHou yeah, i was remembering that were splitted in some way. thank you.

:+1: We use git to track features and bugs and I am closing this issue since problem solved.
Feel free to reopen it if you have other questions :) Thanks for understanding.

Thank you @jannyHou .. It's working!

i suggest use between
like this:

where: {
    createdAt: between['2016-10-18', '2016-10-21'],
}

@ruoru maybe in this way.

where: {
    createdAt: { between: ['2016-10-18', '2016-10-21'] }
}

@phra sorry锛宮y writing is wrong, thanks.

Was this page helpful?
0 / 5 - 0 ratings