{"id":23665925,"url":"https://github.com/matter-in-motion/mm-db-schema","last_synced_at":"2026-04-29T20:04:40.072Z","repository":{"id":57299095,"uuid":"101773722","full_name":"matter-in-motion/mm-db-schema","owner":"matter-in-motion","description":"Database schema defenition extension","archived":false,"fork":false,"pushed_at":"2018-05-16T03:06:29.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-30T03:33:32.868Z","etag":null,"topics":["database","extension","matter-in-motion","schema"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/matter-in-motion.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-29T14:58:05.000Z","updated_at":"2018-05-16T03:06:28.000Z","dependencies_parsed_at":"2022-08-26T18:02:31.261Z","dependency_job_id":null,"html_url":"https://github.com/matter-in-motion/mm-db-schema","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matter-in-motion%2Fmm-db-schema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matter-in-motion%2Fmm-db-schema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matter-in-motion%2Fmm-db-schema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matter-in-motion%2Fmm-db-schema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matter-in-motion","download_url":"https://codeload.github.com/matter-in-motion/mm-db-schema/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239668609,"owners_count":19677551,"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":["database","extension","matter-in-motion","schema"],"created_at":"2024-12-29T06:19:59.756Z","updated_at":"2025-12-08T20:30:13.634Z","avatar_url":"https://github.com/matter-in-motion.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Matter In Motion. Database schema extension\n\n[![NPM Version](https://img.shields.io/npm/v/mm-db-schema.svg?style=flat-square)](https://www.npmjs.com/package/mm-db-schema)\n[![NPM Downloads](https://img.shields.io/npm/dt/mm-db-schema.svg?style=flat-square)](https://www.npmjs.com/package/mm-db-schema)\n\nDatabase schema defenition extension for [matter in motion](https://github.com/matter-in-motion/mm) framework\n\n## Usage\n\n[Extensions installation instructions](https://github.com/matter-in-motion/mm/blob/master/docs/extensions.md)\n\n1. Add this extension\n2. Add schema extension for your database\n\nDefine a schema in your resource controller with options:\n\n* __db__ — database name. If you use [mm-db](https://github.com/matter-in-motion/mm-db) extension you can omit this. Default database will be used.\n* __table__ — table name or an object with table name and table creation options.\n* __indexes__ — array of index names or an object with index names and index creation options.\n* __apply__ — function. If you define `apply` function it will be called. `table` and `indexes` options will be ignored. However, you still should still define them to use in your code.\n\nYou can define as many tables as you want.\n\n### Simple example\n\n```js\nController.prototype.schema = {\n  name: {\n    table: 'table_name',\n    indexes: ['index_name1', 'index_name2']\n  }\n}\n```\n\n### Full example\n\n```js\nController.prototype.schema = {\n  name: {\n    db: 'database driver name',\n    table: {\n      'table_name': tableOptions\n    },\n    indexes: {\n      'index_name1': indexOptions1,\n      'index_name2': indexOptions2,\n    }\n  }\n}\n\n```\n\n### Complicated scenarios\n\n```js\nController.prototype.schema = {\n  name: {\n    db: 'database driver name',\n    //this will be used as description only\n    table: 'table_name',\n    indexes: ['index_name1', 'index_name2'],\n    //here is actual schema\n    apply: function(dbDriver, schema) {\n      //do any stuff nessesary and return a promise\n    }\n  }\n}\n\n```\n\nLicense: MIT.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatter-in-motion%2Fmm-db-schema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatter-in-motion%2Fmm-db-schema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatter-in-motion%2Fmm-db-schema/lists"}