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
$where operator in MongoDB query #6311
Comments
+1 And it looks like it's only happening in the server environment Another reproduction https://github.com/ozsay/meteor-where-issue https://github.com/ozsay/meteor-where-issue/blob/master/whereIssue.js |
Passing the function as a string may work. I've only briefly sanity checked, but this seems to be isomorphically working for me
Reference David Glasser's comment on Sep 16th 2013 in the Google Group meteor-talk @ Does mongodb $where operator not work with Meteor collections, even when used in server code?
|
As mentioned in #6311 (comment) (and in https://groups.google.com/forum/#!msg/meteor-talk/ErgCC4g_bB0/UAqlFpEA3g8J), Meteor does not currently support using function literals with Items.find({$where: function () {
return this.owner === 'me';
}}).count()); but this does work: Items.find({ $where: "this.owner === 'me'" }).count(); Getting function literals working with To help provide a more clear separation between feature requests and bugs, and to help clean up the feature request backlog, Meteor feature requests are now being managed under the https://github.com/meteor/meteor-feature-requests repository. This feature request will be closed here, but anyone interested in migrating this feature request to the new repository (to make sure it stays active), can click here to start the feature request migration process. This manual migration process is intended to help identify which of the older feature requests are still considered to be of value to the community. Thanks! |
Thank you. Using a function string syntax works with Mongo JavaScript 3.6 but not a function. Until I found this thread I was going nuts. And...as mentioned above both methods work in the mongo shell. Confusing. |
_1 Upvote_ Hello,
I'm currently running Meteor:
version: 1.2.1
Platform: Linux Ubuntu 14.04.3
Github bug repository: https://github.com/noodlez04/meteor-mongodb-where-bug
The actual problem is this:
When using $where inside a mongodb query, functions do not work.
If i pass:
$where: function () { return false; }
or$where: function () { return true; }
they both work.Trying to simply pass
$where: 'false'
andwhere: 'true'
do work as expected.The code used can be viewed in
bug-reproducer.js
in the root of my git repository.Terminal output:
The text was updated successfully, but these errors were encountered: