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

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -