Reputation: 1371
QUERY
I'm trying to query a collection using the code below, as suggested here. It works fine for venueName but not for venueLocation - I'm guessing it must be something to do with the fact that it's a sub-schema, and I'm not writing the query properly.
var query = {};
if(Session.get('venueNameVar')) {
query.venueName = Session.get('venueNameVar')
}
if(Session.get('venueLocationVar')){
query.venueAddress = {
neighbourhood : Session.get('venueLocationVar')
}
return Venues.find(query);
COLLECTIONS
My main schema and sub-schema work well across the app so far:
//MAIN SCHEMA
Schema.Venues = new SimpleSchema({
venueAddress: {
type: Schema.VenueAddress,
optional: true
}, [...]
//SUB-SCHEMA
Schema.VenueAddress = new SimpleSchema({
neighbourhood: {
type: String,
max: 100,
optional: true
}, [...]
WHAT I'VE TRIED
Schema.venueAddress.neighbourhood = Sesssion.get('venueLocationVar')
- does not workUpvotes: 3
Views: 162
Reputation: 584
can you try to do query['venueAddress.neighbourhood'] = someVal
im not positive that minimongo can search using objects
In other words you have to use dot notation
when doing queries
Upvotes: 2