-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
isSet query operator #1009
Comments
Well if we can't use |
We can use someField: null ==> someField: {$type: 10} I'm fine to introduce connector specific extensions. Each connector should validate such extensions and report errors if a given operator or syntax is not supported. |
Yeah, I was sort of expecting that, in wich case |
@bajtos @raymondfeng is there any timeframe when this feature makes the cut? |
@marcellodesales not really. Can you contribute the feature yourself? |
This already works using the exists method. // REST Url
// /api/<modelName>?filter[where][<propertyName>][exists]=<true|false>
modelName.find({
where: {
propertyName: {
exists: true
}
}
}, callback) The key is https://github.com/strongloop/loopback-connector-mongodb/blob/master/lib/mongodb.js#L488 where it will apply the $ sign to any property it doesn't understand as an else case. |
@jsheely That is specific to mongodb. would be nice if this could be generalized to all dbs. |
@kraman Agreed. I just wanted to be clear that this feature technically can work today. This and the related issues make it seem like it wasn't possible. While it is not a baked part of the abstracted API it is very nice that it can fall down into the specific implementations of the provider and still be handled. |
@kraman What's your expectation for relational DBs? Do you interpret |
@raymondfeng yes, typically it would be |
@jsheely, the approach you mentioned doesn't work with current datasource-juggler when it coerces where clause: |
nothing is working for the existence of a field in a document. |
+1. Having the same probem as @kblcuk |
Isn't this a very common use case, I cant believe there is no solution ? |
@pmoelgaard we've worked around it by introducing |
This is redonk. High priority for my team +5 |
The automatic passthrough of unrecognised properties actually doesn't work for this on MongoDB. |
The reason for this bug lies with this line https://github.com/strongloop/loopback-datasource-juggler/blob/master/lib/dao.js#L1238 In my case, the property I am inspecting is of boolean type. My |
A possible solution for this would be to have the coercion skipped if the value is an object? |
For example see this
throws an error
So how should this be resolved? Any workaround? |
Another option I guess would be to init that date during |
Thanks! But pre-filling the with database with unneeded data, just for the sake of a inappropriate (re-)implementation of an efficient mongodb query wrapper seems a bad practice. |
Currently the DAO breaks this functionality for the mongoDB fall through $exists check.
https://github.com/strongloop/loopback-datasource-juggler/blob/master/lib/dao.js#L1496 |
… data See strongloop/loopback#1009 as for why the extra tests
This is needed for couchbase as well! Any updates on the implementation of this feature? |
I'm finding that the
|
+1 |
+1 |
Never mind, figured out I was spelling "exists" as "exist"...For any one interested here is how to do it with stringified JSON via REST (with MongoDb as the data repo):
|
maybe sometime filter have |
|
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. |
got this error with a date type as well. Have to add null data :( |
I am also getting this issue. |
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. |
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 |
It is still an issue! |
Guessing now that we are in active LTS this wont be fixed :( |
We should add support for something like this:
This would allow you to query for undefined fields using
$isset
in mongodb andNULL
in SQL databases.The text was updated successfully, but these errors were encountered: