sac Dahal sac Dahal - 1 year ago 86
Javascript Question

What does - mean when querying

I came across a certain query and I am not able to figure out what exactly it does:

parkSchema.statics.findAllParkSlots = function(params, callback){
return this.findById(params.park_location_id, '-_id slots').exec(callback);

Any idea what does

Answer Source

findById is not a MongoDB function, but comes from the Mongoose library (assuming you are using that one).

The first parameter is the _id, the second one defines the projection (which fields to select): You name the fields you want, or you prefix the fields with - that you don't want. In this case "slots and not _id" (which is otherwise always included, even if not explicitly mentioned).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download