{"id":18974296,"url":"https://github.com/alexandrebonaventure/vuex-jsdata-plugin","last_synced_at":"2025-07-21T07:03:53.253Z","repository":{"id":66237421,"uuid":"69826373","full_name":"AlexandreBonaventure/vuex-jsdata-plugin","owner":"AlexandreBonaventure","description":"A plugin for syncing Vuex store with js-data","archived":false,"fork":false,"pushed_at":"2017-06-08T07:29:24.000Z","size":20,"stargazers_count":19,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-19T22:26:17.945Z","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/AlexandreBonaventure.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-10-02T22:44:10.000Z","updated_at":"2024-01-24T08:34:37.000Z","dependencies_parsed_at":"2023-02-20T16:31:17.310Z","dependency_job_id":null,"html_url":"https://github.com/AlexandreBonaventure/vuex-jsdata-plugin","commit_stats":{"total_commits":25,"total_committers":2,"mean_commits":12.5,"dds":0.28,"last_synced_commit":"0418477fa2303fcbccc615150354672599464aac"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/AlexandreBonaventure/vuex-jsdata-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexandreBonaventure%2Fvuex-jsdata-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexandreBonaventure%2Fvuex-jsdata-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexandreBonaventure%2Fvuex-jsdata-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexandreBonaventure%2Fvuex-jsdata-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlexandreBonaventure","download_url":"https://codeload.github.com/AlexandreBonaventure/vuex-jsdata-plugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexandreBonaventure%2Fvuex-jsdata-plugin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266255244,"owners_count":23900098,"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-08T15:14:35.989Z","updated_at":"2025-07-21T07:03:53.233Z","avatar_url":"https://github.com/AlexandreBonaventure.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vuex-jsdata-plugin\nA simple attempt to help using jsdata alongside Vue.js:\nThis plugin syncing Vuex store with js-data\nAfter each injection made by js-data some silent mutations are triggered to ensure vuex store is kept in sync with your ressources (and trigger reactivity).\n\nRead more : https://github.com/js-data/js-data/issues/57\n\n# Dependencies\nThis plugin is developed for\n```\nvuex@2.0.x\njs-data@2.9.x\n```\n\nYou're welcome to contribute to help compatibility issues.\n\n# Usage\nWith NPM\n ```npm install vuex-plugin-jsdata```\n\nThen when you setup vuex:\n```\nimport jsdataPlugin from 'vuex-plugin-jsdata'\nimport yourJsDataStore from 'xxxx'\n\nconst plugins = [\n  jsdataPlugin(yourJsDataStore),\n  ... // other plugins\n]\n\nnew Vuex.Store({\n  // state,\n  // actions,\n  // mutations,\n  plugins,\n})\n\n```\n# How does it work ?\nEvery change in a js-data ressource are made with the DSInject method.\nThe plugin manage the state tree(vuex) under a DS module by listening to the afterInject hook (js-data)\n\n## mutation\nvuex-plugin-jsdata fire only one silent mutation :\n``REFRESH_DATASTORE``\n\n## getters\nAlthough all local ressources injected in the jsdata-store can be found in the vuex store under the namespaced module DS, the plugin provide automatic getters for every model.\n\nEx:\n```\n// Register a model in js-data\n\nexport const User = store.defineResource({\n  name: 'user',\n  endpoint: 'users',\n})\n```\n```\n// in a .vue component\n\u003cscript\u003e\n  import { mapGetters } from 'vuex'\n\n  export default {\n    name: 'User',\n    props: {\n      id: { required: true },\n    },\n    computed: {\n      ...mapGetters(['DSUser']),\n      user() {\n        return this.DSUser[this.id]\n      },\n    },\n  }\n\u003c/script\u003e\n\n\u003ctemplate lang=\"jade\"\u003e\n  div.user\n    pre {{ user | json }}\n\u003c/template\u003e\n\n```\n## global helper\nThis plugin provide a handy way to make a ressource available inside components.\n### mapRessources\nmapRessources([\n  { nameOfTheGetter: [nameOfTheRessource:string, id_key:string]},\n  ...\n])\nmapRessources is a getter factory designed to get a single record which id is computed from $vm[id_key].\nIts really useful for getting specific records dynamicly (eg: get user with id picked from router params)\nexample:\n```\n// in store - DSUsers: { 1: { name: 'Alex' } }\n// component definition\n// using the object spread operator\n$vm = {\n  data() {\n    return {\n      user_id: 1\n    }\n  },\n  computed: {\n    ...mapRessources([\n      { user: ['User', 'user_id'] }\n      { userFromRoute: ['User', '$route.params.id'] } // with vue-router\n    ]),\n  }\n}\n// Log\n$vm.user.name -\u003e 'Alex'\n$vm.userFromRoute.name -\u003e 'Alex'\n```\n\n# Example\nClone the repo and run\n```\nnpm install\nnpm run example-simple\n=\u003e go to /examples/simple\n```\n\nmore to come ...\n\n# TO-DO\n  [ ] handle config options\n  [ ] some examples\n\n# Contributions\nare welcome :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexandrebonaventure%2Fvuex-jsdata-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexandrebonaventure%2Fvuex-jsdata-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexandrebonaventure%2Fvuex-jsdata-plugin/lists"}