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 -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -