When defining a query with Mongoose, you can use:
query.select({somefieldname: 0}) // selects everything but 'somefieldname'
query.select({somefieldname: 1}) // selects only 'somefieldname' & '_id'
However, when I combine them:
query.select({somefieldname1: 0, somefieldname2: 1})
I receive an error. I'm fairly new to Mongoose so perhaps I am overlooking something, any suggestions? Thanks.
You cannot combine inclusion and exclusion semantics in a single projection with the exception of the _id field.