Domanda

I am currently experimenting with the ShareJS implementation for operational transformation (the JSON API in particular). The wiki was not very clear on what would happen if I deleted a parent JSON object, and another operation came in which was inserting into a child JSON. Will the parent JSON be recreated, or will it be a no-op?

E.g.

{"aa":
  {"bb":
    {"cc":"dd"}
  }
}
//Operation A and B comes in carrying the same version number
//Op A deletes "aa", Op B modifies "cc"
//What happens? (assuming A comes in slightly earlier and is processed first)
È stato utile?

Soluzione

Just checked it myself:

op1 = [{p: ["aa"], od: {"bb": {"cc":"dd"}} }] // Deletes "aa"
op2 = [{p: ["aa", "bb", "cc"], od: "dd", oi: "ee"}] // Modifies "cc"
console.log(json.transform(op2, op1, 'left'))
>> []

This means, that when op2 is transformed over op1, it becomes no-op -> no object will be recreated.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top