Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (47.6k points)

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?

2 Answers

0 votes
by (106k points)

The “_v” field in Mongoose is the versionKey is a property set on each document when first created by Mongoose. This key-value contains the internal revision of the document. The name of this document property is configurable. So the default is __v.

The application you can configure as follows:-

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

0 votes
by (107k points)

If you don't need the versionKey then just set it as false, refer to the following code:

var UserSchema = new mongoose.Schema({

    nickname: String,

    reg_time: {type: Date, default: Date.now}

}, {

    versionKey: false // You should be aware of the outcome after set to false

});

If you are a beginner and want to know more about the mongodb architecture then do refer the link. 

1.2k questions

2.7k answers

501 comments

693 users

Browse Categories

...