I have a db collection where I need to write if/else kind of query with string datatype. Tried with $cond
and $switch
but they don't seem to be working.
Requirement is:
{
{
name: 'xyz',
state: 'ABC'
},
{
name: 'abc',
state: 'XYZ'
},
{
name: 'xyz',
state: 'ABC'
},
{
name: 'mno',
state: 'MNO'
}
}
I need to write condition if user name
is 'xyz' then and then only state
should be used for searching else not.
Aucun commentaire:
Enregistrer un commentaire