Friday, March 27, 2015

Mongoose value defaulting


Pretty neat way of defaulting object values in mongoose. Say you want to have a default proximity uuid assigned to one of your documents. Simply enclose this in a type and default definition like the one below. Added bonus of being quite readable as well.

beaconProximityUUID: {type: String, default: BEACON_PROXIMITY_UUID}