Search code examples
node.jsmongodbmongoose

What is the "__v" field in Mongoose


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?


Solution

  • 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' })