What is the "__v" field in Mongoose

Simon Lomax picture Simon Lomax · Sep 19, 2012 · Viewed 143.3k times · Source

I'm using Mongoose version 3 with MongoDB version 2.2. I've noticed a __v field has started appearing in my MongoDB documents. Is it something to do with versioning? How is it used?

Answer

Tony The Lion picture Tony The Lion · Sep 19, 2012

From here:

The versionKey is a property set on each document when first created by Mongoose. This keys value contains the internal revision of the document. The name of this document property is configurable. The default is __v.

If this conflicts with your application you can configure as such:

new Schema({..}, { versionKey: '_somethingElse' })