Reputation: 102
I want to add a field in an existing document in couchbase. For an example, lets say we have below document in couchbase default bucket:
{"first_name":"Abc", "last_name":"Mno"}
Now I want to add a new field in the json document so that it becomes:
{"first_name":"Abc", "last_name":"Mno", "city":"Xyz"}
I know this feature was not available till mid of 2013 as mentioned in this post. But, it is also mentioned that Couchbase team was working on this feature. Anyone has any update about the same?
Upvotes: 0
Views: 755
Reputation: 4865
Couchbase does not yet do sub-document edits, but it is more than likely just as fast to simply get the existing document, add the field to it and write the document back to the database. There really is not that much overhead here because of the managed cache. The overhead would only really matter for very large documents, IMO. Even if the database did do sub-document edits, some mechanism would have to take the original document from the DB, edit and write it back so the document was contiguous. Right now, it is just your app and not inside the DB.
Behind the scenes, Couchbase will append the new version of the document to the end of the vBucket file and then mark the original as invalid. The auto-compaction job will clean up and delete the old version when it runs.
Upvotes: 1