score:0

Accepted answer

You can't. A simple query in MongoDB can't use values from the document it's querying. You can only use values that are constant throughout the query.

Valid Query:

{
    FirstName : "bar"
}

Invalid Query:

{
    FirstName : LastName
}

You can however acheive that by other means, for example MongoDB's aggregation framework


Related Query

More Query from same tag