Meteor $ and $ or
I am trying to do $ and then $ or in Meteor for my mongo request I have the following but it doesn't seem to work
I would like the request to match the docs where the organizationId key has a value in the user.organizationId variable AND where the type key is either "conversion" or "transitional"
{
organizationId: user.organizationId,
$and:[
{ $or:[
{type: 'conventional'},
{type: 'transition'}
]}
]
};
I cannot use $ not as I am sure it is not supported in Meteor. Right now the package I'm using doesn't support it.
source to share
The following query describes what you need as it uses an operator to match documents, type or . The operator is implicitly provided when you supply a comma-separated list of expressions. Using an explicit AND with an operator is only necessary when you need to specify the same field or operator in multiple expressions. $in
'converntional'
'transition'
$and
$and
I would like the request to match the documents where the organizationId key has a value in the user.organizationId variable AND where the key type is either "conversion" or "transition"
{
organizationId: user.organizationId,
type: {
$in : ['conventional', 'transition']
}
}
source to share