Skip to content

A library to convert json patches in mongo update queries

License

Notifications You must be signed in to change notification settings

ZaninAndrea/json-patch-to-mongo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON Patches to Mongo

This utility converts JSON patches to MongoDB update queries.

Using the package

To install the package run

go get github.com/ZaninAndrea/json-patch-to-mongo

Then you can use the utility simply by passing the JSON Patches as []byte to the ParsePatches function

patches := []byte(`[
    { "op": "add", "path": "/hello/0/hi/5", "value": 1 },
    { "op": "add", "path": "/hello/0/hi/5", "value": 2 },
    { "op": "replace", "path": "/world", "value": {"foo":"bar"} }
]`)
updateQuery, err := ParsePatches(patches)

Credits

This is a Go port of the JavaScript library jsonpatch-to-mongodb.

About

A library to convert json patches in mongo update queries

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages