8

Today I came to know about versioning concept in MongooseJS(here Mongoose v3 part 1 :: Versioning). But I have question here, I like the versioning feature of Mongoose, but what should I do when my schema changes ?

For example, initially my schema looks like,

{
 "_id": String,
 "title": String,
 "description": String
}

Since I didn't know about versioning, i didn't add any versionKey option, just used the default versionKey, __v.

I created few documents with this above schema. Later I modified the schema as,

{
 "_id": String,
 "title": String,
 "description": String,

 "comments": Array
}

Here comes the problem, If I create any new document after this schema change I could able to add/push comments to the document.

But If I want to add/push comments to the document which were created with initial schema, I couldn't able to do, it throws Versioning Error: No matching document found.

Is there anyway to overcome this problem without disabling or skipping the versioning ?

Kamalakannan J
  • 2,818
  • 3
  • 23
  • 51

0 Answers0