{"id":19343080,"url":"https://github.com/gdibble/ampersand-json-patch","last_synced_at":"2025-07-06T20:04:46.691Z","repository":{"id":33125210,"uuid":"36764383","full_name":"gdibble/ampersand-json-patch","owner":"gdibble","description":"Adds JSON Patch (RFC 6902) support to Ampersand models.","archived":false,"fork":false,"pushed_at":"2015-06-05T18:05:40.000Z","size":93,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-23T18:14:51.535Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gdibble.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-02T21:59:43.000Z","updated_at":"2021-01-15T01:34:37.000Z","dependencies_parsed_at":"2022-09-12T17:22:44.697Z","dependency_job_id":null,"html_url":"https://github.com/gdibble/ampersand-json-patch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdibble%2Fampersand-json-patch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdibble%2Fampersand-json-patch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdibble%2Fampersand-json-patch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdibble%2Fampersand-json-patch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gdibble","download_url":"https://codeload.github.com/gdibble/ampersand-json-patch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240449891,"owners_count":19803125,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T03:37:16.496Z","updated_at":"2025-02-24T09:16:53.181Z","avatar_url":"https://github.com/gdibble.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ampersand-json-patch\nAdds JSON Patch (RFC 6902) support to Ampersand models.\n\n###**[Don't patch like an idiot.](http://williamdurand.fr/2014/02/14/please-do-not-patch-like-an-idiot/)**\n\n## Usage\n\n`npm install --save ampersand-json-patch`\n\n**ampersand-json-patch** is used as a [mixin](https://ampersandjs.com/learn/base-objects-and-mixins#using-and-re-using-mixins).\n\n```javascript\nvar AmpersandModel = require('ampersand-model');\nvar PatchMixin = require('ampersand-patch-json');\n\nvar CarModel = AmpersandModel.extend(PatchMixin, {\n\turlRoot: '/api/cars',\n\tprops: {\n\t\tid: 'number',\n\t\tmake: 'string',\n\t\tmodel: 'string',\n\t\tyear: 'number'\n\t},\n\tinitialize: function() {\n\t\tthis.initPatcher();\n\t}\n});\n\n```\n\nModels now have a `patch()` method.\n\n```javascript\nvar myCar = new CarModel({id: 1, make: 'Honda', model: 'CR-V', year: 1999});\n\nmyCar.set({model: 'Civic'});\n\nmyCar.patch();\n```\n\nGenerates the following HTTP PATCH request to `/api/cars/1`:\n\n```javascript\n[ { op: 'replace', path: '/model', value: 'Civic' } ]\n```\n\nThe `patch` method also accepts `success` and `error` callbacks in the options hash, just like Ampersand's `save`.\n\nInitializing the patcher with `initPatcher({listeners: true})` will fire a patch to the server automatically on every `change` event to your model.\n\nSee [JSON-Patch](https://github.com/Starcounter-Jack/JSON-Patch) for all supported operations.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgdibble%2Fampersand-json-patch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgdibble%2Fampersand-json-patch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgdibble%2Fampersand-json-patch/lists"}