I am currently working with sharedb (https://share.github.io/sharedb/) and the operationel transformation type json0 (https://github.com/ottypes/json0). I need to add a key (path) to a JSON object afterwards, which should be shared via sharedb.
For example, the key "key2" should be added to the following JSON object:
{
key1: 'some_value',
}
Unfortunately, according to the documentation of json0 (https://github.com/ottypes/json0), there is no operation for this, which surprises me a lot. How can I add a new key that will be recognized by sharedb? Simply adding the key (path) locally makes sharedb not recognize it!
The docs you shared say:
{p:[path,key], oi:obj}
inserts the objectobj
into the object at[path]
with keykey
.
So you'd want to use that oi
("object insert") op shape:
const op = [{p: ['key2'], oi: 'some_other_value'}]
doc.submitOp(op)