How to save mongoose virtuals How to save mongoose virtuals express express

How to save mongoose virtuals


Virtuals are document properties that you can get and set but that do not get persisted to MongoDB. The getters are useful for formatting or combining fields, while setters are useful for de-composing a single value into multiple values for storage.

It's mean we can use Virtuals for only data preparation for example we can merge first name and last name or populate the document with reference.


Mongoose supports virtual attributes. Virtual attributes are attributes that are convenient to have around but that do not get persisted to mongodb.

You cannot save virtual data, its only getter