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

What is happening when Matlab is starting a "parallel pool"? -

php - Cannot override Laravel Spark authentication with own implementation -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -