josephg / ShareJS

Collaborative editing in any app
Other
4.97k stars 456 forks source link

MongoDB ops appear to store redundant data #160

Open bfirsh opened 11 years ago

bfirsh commented 11 years ago

This is a small issue, but the MongoDB schema seems unnecessarily verbose:

{
  opData: {
    op: [
      {
        p: [
          "text",
          611
        ],
        si: " "
      }
    ],
    meta: {
      source: "b1c6063989dbca821fd9ded844031305",
      ts: 1356560181754
    }
  },
  _id: {
    doc: "draft-text-b2aa543046d47579aad4738a",
    v: 2
  }
}

Perhaps the opData object could be flattened into the root object? This could be changed in a backwards compatible way by checking for the existence of the opData object.

(cc @zamfi - I think you might know the answer to this!)

wmertens commented 11 years ago

So you're just talking about the opData wrapping object, or did you have something more in mind?

Since we don't have _id fields in ops, I think removing opData is a good idea.

bfirsh commented 11 years ago

Yep - I just meant removing the opData wrapping object. I'll put together a pull request.