Object.findOne({
where: {
and: [{user_id: user_id}]
}, function(err, object){
console.log(object) // undefined
});
Object.find({
where: {
and: [{user_id: user_id}]
}, function(err, object){
console.log(object) // []
});
findOne = no results returns 'undefined' // This is easy to check for for example ... if(typeof object !== 'undefined'){}
but...
find on no results returns empty array [] or nothing.
Hi @evinw,
Could you please provide a sample repo using our loopback-sandbox to reproduce the issue?
Thanks!
@evinw
Do you still have the same issue? If so could you please provide a sample repo to reproduce the issue? Otherwise if it works, please let us know, so we can close this ticket.
Thanks a lot!
Closing this issue due to inactivity; please feel free to comment if you still have the same issue.
Thanks!
@Amir-61 querying the find method with object id returns the object, but when querying with any other params returns an empty array :
File model has : id, imgId and eventId
File.find({where: {eventId: eventId}},function(err,res){
console.log("found Image " + res)
cb(err,res);
})
Any idea why?
I found out why, in the mode definition JSON file ( for me File.json), I needed to add "strictObjectIDCoercion": true to the options array, now querying with any params works
Most helpful comment
I found out why, in the mode definition JSON file ( for me File.json), I needed to add
"strictObjectIDCoercion": trueto the options array, now querying with any params works