{"id":49868850,"url":"https://github.com/serenysoft/rxdb-extra","last_synced_at":"2026-05-15T04:07:38.201Z","repository":{"id":350429547,"uuid":"1206862650","full_name":"serenysoft/rxdb-extra","owner":"serenysoft","description":"Extra Plugins for RxDB","archived":false,"fork":false,"pushed_at":"2026-05-04T14:50:09.000Z","size":196,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-05-04T16:36:22.477Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/serenysoft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-10T10:23:35.000Z","updated_at":"2026-05-04T14:50:15.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/serenysoft/rxdb-extra","commit_stats":null,"previous_names":["serenysoft/rxdb-extra"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/serenysoft/rxdb-extra","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serenysoft%2Frxdb-extra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serenysoft%2Frxdb-extra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serenysoft%2Frxdb-extra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serenysoft%2Frxdb-extra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serenysoft","download_url":"https://codeload.github.com/serenysoft/rxdb-extra/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serenysoft%2Frxdb-extra/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33053179,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-15T02:00:06.351Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2026-05-15T04:07:36.905Z","updated_at":"2026-05-15T04:07:38.195Z","avatar_url":"https://github.com/serenysoft.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RxDB extra plugins\n\nThis package provides small utility plugins for RxDB, including searchable fields and automatic timestamps.\n\n## Install\n\n```bash\nnpm i rxdb-extra --save\n```\n\n## Simple search\n\n```ts\nimport { addRxPlugin, createRxDatabase } from 'rxdb';\nimport { getRxStorageMemory } from 'rxdb/plugins/storage-memory';\nimport { RxDBSimpleSearchPlugin } from 'rxdb-extra';\n\naddRxPlugin(RxDBSimpleSearchPlugin);\n\nconst database = await createRxDatabase({\n  name: 'appdb',\n  storage: getRxStorageMemory(),\n});\n\nawait database.addCollections({\n  users: {\n    schema: {\n      version: 0,\n      primaryKey: 'id',\n      type: 'object',\n      properties: {\n        id: { type: 'string', maxLength: 100 },\n        name: { type: 'string' },\n        age: { type: 'integer' },\n        searchIndex: { type: 'string', default: '' },\n      },\n    },\n    options: {\n      searchable: {\n        fields: ['name', 'age'], // required\n        index: 'searchIndex',\n      },\n    },\n  },\n});\n\nconst doc = await database.users.insert({\n  id: '1',\n  name: 'Bill Gates',\n  age: 67,\n});\n\nconsole.log(doc.toJSON().searchIndex); // \"bill gates 67\"\n```\n\n`searchable.fields` is required and defines which attributes are merged into the stored search string.\n\n### Modify values before indexing\n\nIf you want to keep the default serializer but normalize a specific field first, use `modifier`.\nThis is useful for formatting date values.\n\n```ts\noptions: {\n  searchable: {\n    fields: ['name', 'createdAt'],\n    index: 'searchIndex',\n    modifier: (value, field) =\u003e\n      field === 'createdAt' ? String(value ?? '').slice(0, 10) : value,\n  },\n}\n```\n\n### Custom serializer\n\n```ts\noptions: {\n  searchable: {\n    fields: ['name', 'age'],\n    index: 'searchIndex',\n    serializer: (data, fields) =\u003e\n      fields.map((field) =\u003e String(data[field] ?? '')).join('|').toUpperCase(),\n  },\n}\n```\n\nYou can then query the stored field with regular RxDB selectors, for example using `$regex`.\n\n## Strict schema\n\nThe strict-schema plugin removes properties that are not declared in `schema.properties`.\nIt runs on insert and save, so out-of-schema fields are stripped before documents are persisted.\n\n```ts\nimport { addRxPlugin, createRxDatabase } from 'rxdb';\nimport { getRxStorageMemory } from 'rxdb/plugins/storage-memory';\nimport { RxDBStrictSchemaPlugin } from 'rxdb-extra';\n\naddRxPlugin(RxDBStrictSchemaPlugin);\n\nconst database = await createRxDatabase({\n  name: 'appdb',\n  storage: getRxStorageMemory(),\n});\n\nawait database.addCollections({\n  users: {\n    schema: {\n      version: 0,\n      primaryKey: 'id',\n      type: 'object',\n      properties: {\n        id: { type: 'string', maxLength: 100 },\n        name: { type: 'string' },\n        age: { type: 'integer' },\n      },\n      required: ['id', 'name'],\n    },\n  },\n});\n\nconst doc = await database.users.insert({\n  id: '2',\n  name: 'Alan Turing',\n  age: 41,\n  extraField: 'will be removed',\n});\n\nconsole.log(doc.toJSON());\n// { id: '2', name: 'Alan Turing', age: 41 }\n```\n\nNotes:\n- Only top-level keys are filtered.\n- Fields declared in `schema.properties` are preserved.\n\n## Timestamps\n\nThe timestamps plugin automatically maintains `createdAt` and `updatedAt` fields for each document.\nIt is enabled by default and can also be configured per collection or at database level.\nThe timestamp fields must already be declared in `schema.properties`; the plugin does not mutate the schema.\n\n```ts\nimport { addRxPlugin, createRxDatabase } from 'rxdb';\nimport { getRxStorageMemory } from 'rxdb/plugins/storage-memory';\nimport { RxDBTimestampsPlugin } from 'rxdb-extra';\n\naddRxPlugin(RxDBTimestampsPlugin);\n\nconst database = await createRxDatabase({\n  name: 'appdb',\n  storage: getRxStorageMemory(),\n  options: {\n    timestamps: true,\n  },\n});\n\nawait database.addCollections({\n  users: {\n    schema: {\n      version: 0,\n      primaryKey: 'id',\n      type: 'object',\n      properties: {\n        id: { type: 'string', maxLength: 100 },\n        name: { type: 'string' },\n        createdAt: { type: 'string', format: 'date-time', final: true },\n        updatedAt: { type: 'string', format: 'date-time' },\n      },\n      required: ['id', 'name', 'createdAt', 'updatedAt'],\n    },\n  },\n});\n```\n\nTo disable timestamps for a specific collection, set `timestamps: false`:\n\n```ts\noptions: {\n  timestamps: false,\n}\n```\n\nYou can also customize the field names with:\n\n```ts\noptions: {\n  timestamps: {\n    createdAt: 'created_on',\n    updatedAt: 'updated_on',\n  },\n}\n```\n\nTo format generated timestamps before save, use `modifier`:\n\n```ts\noptions: {\n  timestamps: {\n    modifier: (value, field) =\u003e\n      value instanceof Date ? value.toISOString().slice(0, 10) : value,\n  },\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserenysoft%2Frxdb-extra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserenysoft%2Frxdb-extra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserenysoft%2Frxdb-extra/lists"}