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

MiniMongo doesn't work with array-based queries #126

Closed
skyronic opened this Issue May 7, 2012 · 3 comments

Comments

Projects
None yet
3 participants
@skyronic

skyronic commented May 7, 2012

Create a new record in a collection:

 Stories.insert({list:[{foo:42, bar:32}, {foo: 50, bar:90}]})

Running the query {'list.foo':42} in the mongo shell meteor mongo works fine and retrieves the record. However, running it on the browser fails with an error "TypeError: Cannot read property 'foo' of undefined"

The immediate code generated by minimongo to be eval'ed is:

_func = (function(f,literals){return function(doc){return (f._matches(doc["list"], function(x){return (function(x){return f._matches_plus(x,function(x){return x===42;});})(x["foo"]);}));};})
@debergalis

This comment has been minimized.

Member

debergalis commented May 11, 2012

Works for me.

Stories.insert({list:[{foo:42, bar:32}, {foo: 50, bar:90}]});
--> "cc4ee017-faa6-4244-84e5-6fc02b72c609"
Stories.findOne({'list.foo':42});
--> Object
Stories.findOne({'list.foo':40});
--> undefined
@skyronic

This comment has been minimized.

skyronic commented May 20, 2012

@debergalis - I tried the same thing in my Chrome 19 Inspector on Meteor 0.3.6 and still get the same error

http://i.imgur.com/3g3lP.png

@skyronic

This comment has been minimized.

skyronic commented May 21, 2012

@debergalis - I found the issue.

While doing Collection.insert(object), I didn't have the array item (list) in the object. If I added it later (using update($push) - it doesn't seem to work. It does seem like a little odd behavior but nothing that can't be worked around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment