node.js - Mongoose Model : get fields displayed in all the document while retrieving even if fields are missing in saved collection -


considering collection, photo field not defined in documents. when try retrieve photo collection. following response

{ "_id" : objectid("5757ea898a9d52801b98cc25"), }  { "_id" : objectid("5757ea898a934dsadsadsd25"), "photo" : 'user.jpg' } 

is there chance can fields displayed in document if missing (something this)

{  "_id" : objectid("5757ea898a9d52801b98cc25"),  "photo": undefined }  {  "_id" : objectid("5757ea898a934dsadsadsd25"),  "photo" : 'user.jpg' } 

just required add default value key in schema definition. if data key not available in document, returns default value.


Comments

Popular posts from this blog

angular - DownloadURL return null in below code -

python 2.7 - Given three nested dictionaries, sort the top two nested dictionaries from a value in the innermost dictionary? -