Sub-Documents / new value fields PHP SDK


#1

I am trying to add a new piece of information to an existing document and I am not sure how to do so, I am not understanding the documentation for it.

Example:
SELECT META(bucketname) As Meta FROM bucketname WHERE Meta().id = “’.$key.’”’)
I pull a document and it shows the meta data:
ID:
FLAGS:
CAS:
etc…

I want to add to this list of meta data with my own field and put, for example, EXP DATE: some value

Im trying to use mutatein and upsert but im not figuring out the path it desires.

Can someone show me a good example of how i could do this and have access to values in couchbase on application side ?


#2

You can find subdocument documentation here:
https://developer.couchbase.com/documentation/server/5.5/sdk/subdocument-operations.html
http://docs.couchbase.com/sdk-api/couchbase-php-client-2.5.1/classes/Couchbase.MutateInBuilder.html

Here is an example on how to modify meta attributes (XATTRs). Regular attributes are exactly the same but without 'xattr' => true option.

I can help more if you will provide your code example, logs or failure messages.