json-patch / json-patch2

A possibile revision to the JSON-Patch format
44 stars 0 forks source link

Borrow operators from Mongo? #22

Open ethanresnick opened 6 years ago

ethanresnick commented 6 years ago

Mongo's patch document format probably wouldn't make sense to copy/standardize directly, as it has some pretty big limitations (e.g., it's only possible to apply one operation to each document field) and it doesn't target values with JSON Pointer, so in that sense it doesn't compose well with existing standards.

That said, Mongo does have a pretty extensive set of update operators that have, presumably, proven themselves to be sufficient after/through pretty heavy developer use. (After all, I imagine Mongo's document patching format is by far the most widely-used JSON patch format.) Maybe these operators could offer a good starting point for JSON Patch 2?

HappyNomad commented 6 years ago

I've built the front-end of a large mobile app that communicates user changes to the back-end via the JSON Patch derivative I described in #20. The back-end is coming along well, and next I must apply #20-style operations to data in Mongo. I plan to code a layer that translates those operations into Mongo's update format.

While developing this mobile app, I've also created a .NET Standard 2.0 client-side library that tracks changes to domain objects and packages them into a #20-style document. I envision this library becoming a full-fledged synchronization framework for occasionally-connected mobile apps. I'd love to eventually make it open-source to promote the adoption of JSON Patch by document databases like Mongo.

Now I must focus on translating the #20-style operations to Mongo updates. As with the client-side library, I hope to make this server-side translation code open-source, too. Is anyone interested in potentially using or helping further develop these? The client-side library is polished and done, but the server-side one is a work-in-progress. In particular, I could use help interpreting Mongo updates in terms of #20-style operations.

mitar commented 4 years ago

I would be against it. That should probably be a completely different standard. The beauty of JSON patch is that it is simple. MongoDB is complicated. There are also many special cases and edge cases which have to be handled differently. Also, the original query language was not enough and recently they had to add more queries to support like modifying arrays in multiple places at once and so on. So I would say that from my observation the language is far from complete and is changing all the time.