Hi
I am using google proto objects that which gets converted into JSONArray document and then store into couchbase.
Something like this:
My ProtoObjec1 Array which gets converted to JSONArrayDocument is as follows
[
{
“field0”: “0”,
“field1”: “aaaaaa”,
“field2”: “bbbbbb”,
“field3”: “cccccc”,
“field4”: 1111111,
“field5”: “dddddd”
},
{
“field0”: “0”,
“field1”: “aaaaaa”,
“field2”: “bbbbbb”,
“field3”: “cccccc”,
“field4”: 2222222,
“field5”: “dddddd”
}
]
In couchbase i will store this as
Document Key: 1111
Document Value as the below JSONArrayDocument:
[{
“field0”: “0”,
“field1”: “aaaaaa”,
“field2”: “bbbbbb”,
“field3”: “cccccc”,
“field4”: 1111111,
“field5”: “dddddd”
},
{
“field0”: “0”,
“field1”: “aaaaaa”,
“field2”: “bbbbbb”,
“field3”: “cccccc”,
“field4”: 2222222,
“field5”: “dddddd”
}]
So when i do an upsert from Java SDK and add a new JSONDocument to the existing JSONArrayDocument above , i want to inject a field namely “field6” with the latest timestamp value or something similar in the new JSONDocument. added to the Array. By this i will know that this JSONDocument is added newly.(something like a dirtly flag setting)
Example output needed:
[{
“field0”: “0”,
“field1”: “aaaaaa”,
“field2”: “bbbbbb”,
“field3”: “cccccc”,
“field4”: 1111111,
“field5”: “dddddd”
},
{
“field0”: “0”,
“field1”: “aaaaaa”,
“field2”: “bbbbbb”,
“field3”: “cccccc”,
“field4”: 2222222,
“field5”: “dddddd”
},
{
“field0”: “0”,
“field1”: “aaaaaa”,
“field2”: “bbbbbb”,
“field3”: “cccccc”,
“field4”: 2222222,
“field5”: “dddddd”
“field6”: “latestTimeStampvalue” or “some-flag to know that this JSONDocument is added newly”
}
]
As this is a google proto object i am not able to add that new field6 into the object from Java side. Is there any way in couchbase by means on N1QL or something to know that which JSONDocument is recently added in the existing array?
Pls let me know your suggestions