{"id":18789612,"url":"https://github.com/joelalejandro/ember-data-patch-persistance","last_synced_at":"2025-04-13T14:06:19.292Z","repository":{"id":33508190,"uuid":"37154158","full_name":"joelalejandro/ember-data-patch-persistance","owner":"joelalejandro","description":"An addon that allows saving partial models with HTTP PATCH.","archived":false,"fork":false,"pushed_at":"2015-06-11T03:32:08.000Z","size":156,"stargazers_count":9,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-13T14:06:13.587Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"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/joelalejandro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-09T19:41:54.000Z","updated_at":"2021-06-17T00:31:47.000Z","dependencies_parsed_at":"2022-08-30T02:40:23.848Z","dependency_job_id":null,"html_url":"https://github.com/joelalejandro/ember-data-patch-persistance","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelalejandro%2Fember-data-patch-persistance","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelalejandro%2Fember-data-patch-persistance/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelalejandro%2Fember-data-patch-persistance/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelalejandro%2Fember-data-patch-persistance/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joelalejandro","download_url":"https://codeload.github.com/joelalejandro/ember-data-patch-persistance/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248724639,"owners_count":21151561,"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-07T21:08:04.441Z","updated_at":"2025-04-13T14:06:19.273Z","avatar_url":"https://github.com/joelalejandro.png","language":"JavaScript","readme":"# Patch Persistance addon for Ember Data\n\nThis addon allows you to save a partial model using the HTTP PATCH verb on a `DS.RESTAdapter`.\n\n## Installation\n\n`ember install ember-data-patch-persistance`\n\n## Usage\n\n### Persisting data\n\nWhenever you want to push data to the server using PATCH, instead of using `.save()`\nyou'll use `.patch()`, setting whatever attributes you want to save:\n\n```js\n// Let's bring a car and change its colour.\nthis.store.findById('car', 1).then(function(car) {\n  car.set('colour', '#ff0000');\n  car.patch().then(function() {\n    // ...\n  });\n})\n```\n\nThis will produce an HTTP request with this payload:\n\n```js\nPATCH /api/cars/1\n{\n  \"car\": {\n    \"colour\": \"#ff0000\"\n  }\n}\n```\n\nThe addon will automatically detect the model's changed attributes and push those\nchanges to the server.\n\n### Forcing attributes into the payload\n\nIt may happen that you must push data to the server, without considering whether\nif such data was modified or not. If that occurs, you can set `alwaysPatch` to\n`true` in the model definition:\n\n```js\n// models/car.js\nimport DS from 'ember-data';\n\nexport default DS.Model.extend({\n  colour: DS.attr('string'),\n  wheels: DS.attr('number'),\n  owner: DS.belongsTo('person', { async: true, alwaysPatch: true })\n});\n```\n\nPatch Persistance plays nice with relationships as long as you follow Ember Data\nconventions.\n\n## Notes\n\n- This addon reopens the `DS.Model` and `DS.RESTAdapter` classes; thus,\n  all extended objects from these classes will have the `.patch()` method\n  available. I'm considering refactoring the addon as a mixin on a future\n  version, provided there is interest enough on such feature.\n\n- The addon has been tested up to Ember Data 1.0.0-beta17, without issues.\n\n## Have an issue?\n\nFeel free to post an issue in this repository! :)\n\n## Have any ideas?\n\nBy all means, feel free to make a PR!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoelalejandro%2Fember-data-patch-persistance","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoelalejandro%2Fember-data-patch-persistance","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoelalejandro%2Fember-data-patch-persistance/lists"}