{"id":19139687,"url":"https://github.com/koheing/firex-store","last_synced_at":"2025-05-06T23:15:28.536Z","repository":{"id":38449802,"uuid":"209917226","full_name":"koheing/firex-store","owner":"koheing","description":"vuex + firestore. you can read or write firestore data, easily","archived":false,"fork":false,"pushed_at":"2023-03-04T04:47:04.000Z","size":1825,"stargazers_count":4,"open_issues_count":12,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-06T23:15:20.843Z","etag":null,"topics":["firebase","firestore","npm-package","nuxt","typescript","vue","vuejs","vuejs2","vuex"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/koheing.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-21T03:13:40.000Z","updated_at":"2021-04-06T11:36:36.000Z","dependencies_parsed_at":"2024-11-09T07:14:48.530Z","dependency_job_id":"42bbca00-1988-41fc-af01-cdffb7e338da","html_url":"https://github.com/koheing/firex-store","commit_stats":null,"previous_names":["nor-ko-hi-jp/firex-store"],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koheing%2Ffirex-store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koheing%2Ffirex-store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koheing%2Ffirex-store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koheing%2Ffirex-store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koheing","download_url":"https://codeload.github.com/koheing/firex-store/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252782835,"owners_count":21803410,"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":["firebase","firestore","npm-package","nuxt","typescript","vue","vuejs","vuejs2","vuex"],"created_at":"2024-11-09T07:14:43.791Z","updated_at":"2025-05-06T23:15:28.509Z","avatar_url":"https://github.com/koheing.png","language":"TypeScript","readme":"# firex-store\n\n[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)\n![Main](https://github.com/nor-ko-hi-jp/firex-store/workflows/Main/badge.svg?branch=develop)\n[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/nor-ko-hi-jp/firex-store/issues)\n\n- `If you use this npm, you can read and write firestore data in Vuex, easily.`\n- It is inspired by [vuexfire](https://github.com/vuejs/vuefire)\n- With this NPM, you can read and write Firestore data in Vuex like the following code\n```js\nimport { to, from, on, firestoreMutations, bindTo, map } from 'firex-store'\nimport { Model } from '~/model'\nimport { firestore } from '~/plugins/firebase'\n\n// Vuex module\nexport default {\n  state: {\n    comments: [],\n    isLoaded: false\n  },\n  mutations: {\n    ...firestoreMutations('collection'),\n    // ...firestoreMutations('all')\n    setIsLoaded: (state, isLast) =\u003e {\n      state.isLoaded = isLast\n    }\n  },\n  actions: {\n    streamSubscribe: ({ state, commit }) =\u003e {\n      const toComment = (data) =\u003e new Model(...data)\n      const ref = firestore.collection('comments')\n      // write code like Rxjs\n      from(ref)\n        .pipe(\n          map(toComment),                                               // option\n          bindTo('comments'),                                           // required\n          (({ isLast }) =\u003e commit('setIsLoaded', isLast))               // option\n        )\n        .subscribe(state, commit /*, { errorHandler, complectionHandler } */)\n    },\n    subscribe: ({ state, commit }) =\u003e {\n      const ref = firestore.collection('comments')\n      from(ref)\n        .mapOf(Model)   // options. Model.fromJson called\n        .bindTo('comments')\n        .subscribe(state, commit, /* { errorHandler, complectionHandler, afterMutationCalled } */)\n    },\n    subscribeOnce: async ({ commit }) =\u003e {\n      const ref = firestore.collection('comments')\n      await from(ref)\n        .mapOf(Model)   // options. Model.fromJson called\n        .bindTo('comments')\n        .subscribeOnce(commit, /* { errorHandler, complectionHandler, afterMutationCalled } */)\n    }\n    unsubscribe: ({ state }) =\u003e {\n      on('comments').unsubscribe(state)\n    },\n    find: async (_, { commentId }) =\u003e {\n      const ref = firestore.collection('comments').doc(commentId)\n      result = await from(ref)\n        .once()\n        .mapOf(Model)   // options. Model.fromJson called\n        .find(/* { errorHandler, completionHandler } */)\n      return result\n    },\n    add: (_, { data }) =\u003e {\n      const ref = firestore.collection('comments')\n      return to(ref)\n        .mapOf(Model)   // options. Model.toJson called\n        .add(data, /* { errorHandler, completionHandler } */)\n    },\n    set: (_, { data, commentId }) =\u003e {\n      const ref = firestore.collection('comments').doc(commentId)\n      return to(ref)\n        .mapOf(Model)   // options. Model.toJson called\n        .transaction()  // options\n        .set(data, /* { errorHandler, completionHandler } */)\n    },\n    mergeSet: (_, { data, commentId }) =\u003e {\n      const ref = firestore.collection('comments').doc(commentId)\n      return to(ref)\n        .mapOf(Model)   // options. Model.toJson called\n        .transaction()  // options\n        .mergeSet(data, /* { errorHandler, completionHandler } */)\n    },\n    delete: (_) =\u003e {\n      const ref = firestore.collection('comments').doc('commentId')\n      return to(ref)\n        .transaction()  // options\n        .delete(/* { errorHandler, completionHandler } */)\n    }\n  }\n}\n```\n\n```js\nimport { FirestoreMapper } from 'firex-store'\n\nclass Model extends FirestoreMapper {\n  static fromJson(data) {\n    return new Model(data.id, `${data.family_name} ${data.first_name}` )\n  }\n\n  static toJson(data) {\n    return { id: data.id, family_name: data.fullName.split(' ')[0], first_name: data.fullName.split(' ')[1] }\n  }\n\n  construnctor(id, fullName) {\n    this.id = id\n    this.fullName = fullName\n  }\n}\n```\n\n## Installation\n\n```\nnpm install --save firex-store\n```\n\n## Example\n\n- [firex-store-sample](https://github.com/nor-ko-hi-jp/firex-store-sample)\n\n## Important\n\n- Return values or state values bound to Firestore has `docId`(documentId in Firestore) property.\n\n- A state in store cannot subscribe to more than one 'collection' and 'document'\n\n- If you'd like to subscribe again after unsubscribing 'collection', set the property of the store you'd like to subscribe to `[]` and then subscribe.\n\n- If you'd like to use helper method in pipe function, use [stream-executor](https://github.com/nor-ko-hi-jp/stream-executor#helper-methods-and-those-descriptions-in-createstream-are) library.\n\n\n## Usage\n- If you'd like to know more, see [here](docs/v1/v1-usage.md), please\n\n\n## Difference from v0\n\n- If you'd like to know more, see [here](docs/v1/v1-difference-from-v0.md), please\n\n## v0 Usage\n\n- If you'd like to know more, see [here](docs/v0/v0-usage.md), please","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoheing%2Ffirex-store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoheing%2Ffirex-store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoheing%2Ffirex-store/lists"}