loopback icon indicating copy to clipboard operation
loopback copied to clipboard

Where clause = problem

Open kogutu opened this issue 9 years ago • 6 comments

Hi, I have problem with this function in AngularJS: Posts.find({ "where": { "and": [ {"month_year": "2017-01"}, {"id_lek": "587ca62f8b90cb2b70b87d9b"} ] } } , function ( posts) { console.log( posts.length); }); }

This function always return me 1(true). In Mongo i have one record, id_lek is not change, i change month_year (in db is value: "2017-01") when I change in {"month_year": "2017-02"} this function return me True but should return 0 (false) beacuse in DB there is no such record.

Please help me! where is wrong?

kogutu avatar Jan 26 '17 12:01 kogutu

Posts.find({ filter: { "where": { "and": [ {"month_year": "2017-01"}, {"id_lek": "587ca62f8b90cb2b70b87d9b"} ] } } } , function ( posts) { console.log( posts.length); }); }

pierreclr avatar Jan 26 '17 14:01 pierreclr

Still not working:/ Now function always return me 0 (false). Look this is my DB Posts (one record) image

This is from console.log (firs row is where clause who use to find function), second row is posts.length

kogutu avatar Jan 26 '17 19:01 kogutu

I know where is problem: When I have id_lek with "-" on end. image

Where clause working, when my id is without "-" where clause is not working.

Tell my why, when add "-" to the id is work, without is don't

kogutu avatar Jan 29 '17 16:01 kogutu

This is kind of weird when I reproduced this issue with mongodb. There is probably some restriction with the format of the number that @kogutu is passing.

I have created a boot script which is:

image

and if i run the code I get:

image

and my mongo collection has the data:

image

But any other format/ same length id_lek /different length id_lek will work. for e.g

image

output:

image

siddhipai avatar Feb 23 '17 17:02 siddhipai

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 23 '17 15:08 stale[bot]

This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.

stale[bot] avatar Sep 06 '17 15:09 stale[bot]