Created
May 31, 2015 06:39
-
-
Save bangonkali/3b4382095b3fe5391db3 to your computer and use it in GitHub Desktop.
Querying within arrays.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return Jit.Core.Firm.find({ $or: [ | |
{'ownerId' : this.userId}, | |
{ 'members': { $elemMatch: { | |
id: this.userId | |
} } } | |
]}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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