Skip to content

Instantly share code, notes, and snippets.

@bangonkali
Created May 31, 2015 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bangonkali/3b4382095b3fe5391db3 to your computer and use it in GitHub Desktop.
Save bangonkali/3b4382095b3fe5391db3 to your computer and use it in GitHub Desktop.
Querying within arrays.
return Jit.Core.Firm.find({ $or: [
{'ownerId' : this.userId},
{ 'members': { $elemMatch: {
id: this.userId
} } }
]});
'members': {
'type': [Object],
'optional': true,
'autoValue': function() {
if (this.isInsert) {
return [{
id: Meteor.userId(),
addedOn: new Date,
active: true,
role: [
Jit.Core.Constants.Member.Admin,
Jit.Core.Constants.Member.Owner,
Jit.Core.Constants.Member.Member
]
}];
}
}
},
"members.$.id": {
type: String, //ForeignObject
optional: true
},
"members.$.addedOn": {
type: Date,
optional: true
},
"members.$.active": {
type: Boolean,
optional: true
},
"members.$.role": {
type: [String],
optional: true
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment