{"id":18829902,"url":"https://github.com/rxstack/memory-service","last_synced_at":"2026-02-26T05:46:04.263Z","repository":{"id":34982820,"uuid":"155418484","full_name":"rxstack/memory-service","owner":"rxstack","description":"In-memory @rxstack/platform service","archived":false,"fork":false,"pushed_at":"2024-10-28T07:58:18.000Z","size":468,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T09:21:34.583Z","etag":null,"topics":["memory","nodejs","platform","rxstack","typescript"],"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/rxstack.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":"2018-10-30T16:21:26.000Z","updated_at":"2024-10-28T07:57:02.000Z","dependencies_parsed_at":"2024-10-28T08:59:58.307Z","dependency_job_id":"9e7cbde8-7c3f-4682-996e-7f4dbd83fe89","html_url":"https://github.com/rxstack/memory-service","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxstack%2Fmemory-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxstack%2Fmemory-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxstack%2Fmemory-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxstack%2Fmemory-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rxstack","download_url":"https://codeload.github.com/rxstack/memory-service/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248818525,"owners_count":21166438,"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":["memory","nodejs","platform","rxstack","typescript"],"created_at":"2024-11-08T01:46:58.481Z","updated_at":"2025-10-29T09:30:03.691Z","avatar_url":"https://github.com/rxstack.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The RxStack Memory Service Module\n\n[![Node.js CI](https://github.com/rxstack/memory-service/actions/workflows/node.js.yml/badge.svg)](https://github.com/rxstack/memory-service/actions/workflows/node.js.yml)\n[![Maintainability](https://api.codeclimate.com/v1/badges/9e8e95e4e45995eb5ddf/maintainability)](https://codeclimate.com/github/rxstack/memory-service/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/9e8e95e4e45995eb5ddf/test_coverage)](https://codeclimate.com/github/rxstack/memory-service/test_coverage)\n\n\u003e In-memory data storage that implements [@rxstack/platform adapter API and querying syntax](https://github.com/rxstack/rxstack/tree/master/packages/platform#services).\n\n## Table of content\n\n- [Instalation](#instalation)\n- [Setup](#setup)\n- [Usage](#usage)\n- [Matcher](#matcher)\n- [Sorter](#sorter)\n\n## \u003ca name=\"instalation\"\u003e\u003c/a\u003e Installation\n\n```\nnpm install @rxstack/memory-service --save\n```\n\n## \u003ca name=\"setup\"\u003e\u003c/a\u003e  Setup\n`MemoryServiceModule` needs to be registered in the `application`. Let's create the application:\n\n```typescript\nimport {Application, ApplicationOptions} from '@rxstack/core';\nimport {MemoryServiceModule} from '@rxstack/memory-service';\n\nexport const APP_OPTIONS: ApplicationOptions = {\n  imports: [\n    MemoryServiceModule\n  ],\n  providers: [\n    // ...\n  ]\n};\n\nnew Application(APP_OPTIONS).start();\n```\n\n## \u003ca name=\"usage\"\u003e\u003c/a\u003e  Usage\n\nFirst we need to create `model interface` and `InjectionToken`:\n\n```typescript\nimport {InjectionToken} from 'injection-js';\nimport {MemoryService} from '@rxstack/memory-service';\n\nexport interface Product {\n  id: string;\n  name: string;\n}\n\nexport const PRODUCT_SERVICE = new InjectionToken\u003cMemoryService\u003cProduct\u003e\u003e('PRODUCT_SERVICE');\n```\n\nthen register it in the application provides:\n\n```typescript\nimport {ApplicationOptions} from '@rxstack/core';\nimport {MemoryService} from '@rxstack/memory-service';\n\nexport const APP_OPTIONS: ApplicationOptions = {\n  // ...\n  providers: [\n    {\n      provide: PRODUCT_SERVICE,\n      useFactory: () =\u003e {\n        return new MemoryService({ idField: 'id', collection: 'products', defaultLimit: 25 });\n      },\n      deps: [],\n    },\n  ]\n};\n```\n\n[Read more about platform services](https://github.com/rxstack/rxstack/tree/master/packages/platform#services)\n\n## \u003ca name=\"matcher\"\u003e\u003c/a\u003e  Matcher\n`Matcher` is used to filter the entries. If you need a custom matcher then implement `MatherInterface`:\n\n```typescript\nimport {FilterCallback, MatcherInterface} from '@rxstack/memory-service';\nimport {Injectable} from 'injection-js';\n\n@Injectable()\nexport class MyCustomMatcher implements MatcherInterface {\n\n  match(query: {[key: string]: any}): FilterCallback {\n    // your custom logic\n  }\n}\n```\n\nand register it in the application providers:\n\n```typescript\nimport {ApplicationOptions} from '@rxstack/core';\nimport {MATCHER_TOKEN} from '@rxstack/memory-service';\n\nexport const APP_OPTIONS: ApplicationOptions = {\n  // ...\n  providers: [\n    // ...\n    { provide: MATCHER_TOKEN, useClass: MyCustomMatcher },\n  ]\n};\n```\n\n\u003e `MyCustomMatcher` will replace the original matcher\n\n\n## \u003ca name=\"sorter\"\u003e\u003c/a\u003e  Sorter\n`Sorter` is used to sort the entries. If you need a custom sorter then implement `SorterInterface`:\n\n```typescript\nimport {SorterInterface} from '@rxstack/memory-service';\nimport {SortInterface} from '@rxstack/query-filter';\nimport {Injectable} from 'injection-js';\n\n@Injectable()\nexport class MyCustomSorter implements SorterInterface {\n\n  sort(sort: SortInterface): ComparisonCallback {\n    // your custom logic\n  }\n}\n```\n\nand register it in the application providers:\n\n```typescript\nimport {ApplicationOptions} from '@rxstack/core';\nimport {SORTER_TOKEN} from '@rxstack/memory-service';\n\nexport const APP_OPTIONS: ApplicationOptions = {\n  // ...\n  providers: [\n    // ...\n    { provide: SORTER_TOKEN, useClass: MyCustomSorter },\n  ]\n};\n```\n\n\u003e `MyCustomSorter` will replace the original sorter\n\n## License\n\nLicensed under the [MIT license](LICENSE).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxstack%2Fmemory-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frxstack%2Fmemory-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxstack%2Fmemory-service/lists"}