Filter on level 2 properties
I am trying to use the ?filter rest method, in order to query on nested properties. However, this doesn't seem to work:
/someResource?filter[where][field.subField][like]=abc
neither does this (which I think is wrong anyway):
/someResource?filter[where][field][subField][like]=abc
Any hints?
Which connector are you using?
Memory in dev, mongo in test and beyond. It's the memory connector that has the issues. We use this one for our dev setup as it resets upon restart...
It's the 'dot' notation that is working with mongo.
This is currently a limitation of the memory connector.
@raymondfeng perhaps we can use something like https://github.com/logicalparadox/filtr or https://github.com/crcn/sift.js to enable this
Well, the nice thing about the memory connector is that it resets, so you test every run with a clean sheet. And of course it's rather speedy ;-)
Of course - however, you can easily reset the test database before you start, like this:
app.datasources['db'].automigrate(next);
Will this drop the entire schema?
Yes, but in the case of MongoDB collections will be empties and indexes re-created. There's no real schema, like with SQL databases.
Sure. Just calling it a 'schema' as a 'habit'
Of course! While collections are being recreated, they are not really removed from the database first. So any obsolete collections will stay around, until you delete them, or the database itself. AFAIK loopback will create the db for you, in case it doesn't exist.
@fabien These libraries are interesting:
- https://github.com/logicalparadox/filtr
- https://github.com/crcn/sift.js
I also looked at:
- https://github.com/louischatriot/nedb
Keep in mind, RDBs won't support nested queries.
@raymondfeng sift.js looks good to me, but it doesn't support skip/limit. nedb does, but it seems quite a bit more involved. It can probably be implemented as a new connector altogether.
Users should be made aware of the limits of RDBM's, which is perhaps easiest when having this as a separate connector - so users have to be explicit about it, instead of relying on the memory connector (for tests and so forth) to support any type (both SQL as well as NoSQL style) of query. It's probably easy to copy the mongodb connector's query normalization code and implement this.
Here are some more libraries of interest:
- https://github.com/kawanet/obop
- http://kawanet.github.io/kagodb/
- https://github.com/sergeyksv/tingodb (but why use this, over mongodb?)
- ~~https://github.com/bevry/query-engine~~ (nevermind, too heavy)
Loosely related: #683 How can i set condition where on include model
How this can work for mysql connector? I have same issue
Looks like Loopback currently does not support nested include filtering. This seems like a huge limitation. I don't believe the db connector should make any difference because ideally the Loopback framework would work the same regardless of what db connector you're using
i'm having the same problem trying to do a nested include. Any solution ?
So are there any plans to support nested properties? Is there any way to get the "native" mongodb-connection so we can query the database without the loopback abstraction?
Hey! I've got the Same Problem. I want to query a List of objects based on the property of an related model as well as the property of the wanted model e.g:
Event.find( { where: { and: [ { endDate : { lt : givenDate}}, { location.name : "Abc" }]} }, cb );
So, am I right, that this is not supported atm?
I want to query a List of objects based on the property of an related model as well as the property of the wanted model. So, am I right, that this is not supported atm?
You are right, this it not supported yet.
so the easiest way would be to just query via SQL? Without any further knowlage: is there any caching mechanism I could use?
Can we upvote on this feature?