{"id":23882643,"url":"https://github.com/divbloxjs/dx-db-sync","last_synced_at":"2026-04-12T18:39:45.178Z","repository":{"id":57699079,"uuid":"411182711","full_name":"divbloxjs/dx-db-sync","owner":"divbloxjs","description":"This tool has been deprecated. This repo will no longer be actively developed. To use Divblox in your project, please visit: https://github.com/divbloxjs/divblox","archived":false,"fork":false,"pushed_at":"2024-03-04T07:23:33.000Z","size":231,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-28T03:05:36.690Z","etag":null,"topics":["database","database-management","divblox","mysql","nodejs"],"latest_commit_sha":null,"homepage":"","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/divbloxjs.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":"2021-09-28T07:38:36.000Z","updated_at":"2024-03-04T07:28:58.000Z","dependencies_parsed_at":"2022-09-26T21:02:14.030Z","dependency_job_id":"aba5d4e9-ce4f-4c7c-85b6-731d5d1687b8","html_url":"https://github.com/divbloxjs/dx-db-sync","commit_stats":{"total_commits":53,"total_committers":2,"mean_commits":26.5,"dds":"0.13207547169811318","last_synced_commit":"a559cebde49e53869a84e179b47d2aa015af5812"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/divbloxjs/dx-db-sync","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divbloxjs%2Fdx-db-sync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divbloxjs%2Fdx-db-sync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divbloxjs%2Fdx-db-sync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divbloxjs%2Fdx-db-sync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/divbloxjs","download_url":"https://codeload.github.com/divbloxjs/dx-db-sync/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divbloxjs%2Fdx-db-sync/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259737914,"owners_count":22903869,"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","database-management","divblox","mysql","nodejs"],"created_at":"2025-01-04T02:56:38.628Z","updated_at":"2026-04-12T18:39:40.151Z","avatar_url":"https://github.com/divbloxjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dx-db-sync\n\u003e[!WARNING]\n\u003eThis tool has been deprecated. This repo will no longer be actively developed. To use Divblox in your project, please visit: https://github.com/divbloxjs/divblox\n\nA tool that synchronises a given database with a provided Divblox data model. Used by divbloxjs to ensure that the underlying database corresponds to the given data model.\n\n## Installation\n\n`npm i dx-db-sync`\n\n## Divblox Data models\n\nA Divblox data model describes the data structure of your project in a json file. It is important to note that\nthe object is case-sensitive and that all keys and values must be provided in camelCase.\nA clean Divblox project should always contain a \"data-model.json\" file that contains the base entity/entities for\nyour project. However, each additional Divblox package can also include its own data model which Divblox will add\nto your project on startup.\n\nThe structure of a data model object is described below.\n\n### Structure\n\n#### Entities\n\nThe data model json file must contain an object, with the highest-level keys/properties being the names of \"Entities\".\nEntities directly translate to database tables when the data model is synchronized with your database.\n\n```\n{\n  \"entityOne\": {\n    ...\n  },\n  \"entityTwo\": {\n    ...\n  },\n  \"entityThree\": {\n    ...\n  },\n  ...\n}\n```\n\n#### Modules\n\nEach entity must have a property called \"module\" that contains the name of the module in which this entity belongs.\nModules are essentially individual databases that the Divblox Data Layer will connect to. It is important to\nknow in which module an entity resides, in order to connect to the correct database when executing sql queries relating\nto the specific entity.\n\n**_Modules are defined in the dxconfig.json file that is used to instantiate your Divblox instance and connect to the\nrelevant database(s)_**\n\n```\n{\n  \"entityOne\": {\n    \"module\": \"main\"\n    ...\n  },\n  \"entityTwo\": {\n    \"module\": \"secondary\"\n    ...\n  },\n  \"entityThree\": {\n    \"module\": \"main\"\n    ...\n  },\n  ...\n}\n```\n\n#### Attributes\n\nEach entity must have a property called \"attributes\". The value of this field must be an object containing each separate\nattribute as a property. An attribute directly translates to a database table column when the data model is synchronized\nwith your database. Therefore, the value of each attribute property must be an object containing its configuration for\nthe database table.\n\n```\n{\n  \"entityOne\": {\n    ...\n    \"attributes\": {\n      \"attributeOne\": {\n        \"type\": \"A valid mysql database table type, e.g INT, VARCHAR, DATETIME, etc\",\n        \"lengthOrValues\": [null|string|int] \"If column type is \"enum\" or \"set\", please enter the values using this format: 'a','b','c'\",\n        \"default\": [null|value|\"CURRENT_TIMESTAMP\"] \"The default value for the column.\",\n        \"allowNull\": \"Whether to allow null or not for the column\"\n      },\n      \"attributeTwo\": {\n        ...\n      },\n      \"attributeThree\": {\n        ...\n      },\n      ...\n    },\n    ...\n  },\n  ...\n}\n```\n\n#### Indexes\n\nEach entity must have a property called \"indexes\". The value of this field must be an array of objects, each describing\nan index to be added to the relevant database table. This array can optionally be left empty.\n\n```\n{\n  \"entityOne\": {\n    ...\n    \"indexes\": [\n      ...\n      {\n        \"attribute\": \"The name of the attribute (The column name in the database) on which to add the index\",\n        \"indexName\": \"The unique name of the index\",\n        \"indexChoice\": [\"index\"|\"unique\"|\"spatial\"|\"text\"],\n        \"type\": [\"BTREE\"|\"HASH\"]\n      }\n      ...\n    ],\n    ...\n  },\n  ...\n}\n```\n\n#### Relationships\n\nEach entity must have a property called \"relationships\". The value of this field must be an object containing each\nseparate relationship entity as a property. An entity can have multiple relationships with another entity. Therefore,\neach relationship is defined as an array containing the unique relationship name for the entity. This translates directly\nto foreign key constraints and columns in the database.\n\n```\n{\n  \"entityOne\": {\n    ...\n    \"relationships\": {\n      \"entityTwo\":[\n        \"relationshipOne\",\n        \"relationshipTwo\",\n        ...\n      ],\n      ...\n    },\n    ...\n  },\n  ...\n}\n```\n\n#### Optional settings\n\nEach entity must have a property called \"options\". The value of this field must be an object containing additional options\nfor the entity. The default options are:\n\n-   \"enforceLockingConstraints\", which tells the Divblox database sync\n    operation to add a column \"lastUpdated\" to the relevant database table. This column is used to apply and manage locking\n    constraints when trying to update the relevant table.\n-   \"isAuditEnabled\", which tells divbloxjs whether or not to audit interactions with this entity\n\nAdditional options can be added here if you want to implement your own functionality on your Divblox data model.\n\n```\n{\n  \"entityOne\": {\n    ...\n    \"options\": {\n      \"enforceLockingConstraints\": [true|false],\n      \"isAuditEnabled\": [true|false]\n    }\n  }\n}\n```\n\n### Example data model\n\nBelow is an example of a more complete, yet fictional data model:\n\n```\n{\n  \"exampleEntityOne\": {\n    \"module\": \"main\",\n    \"attributes\": {\n      \"exampleOneTimeStamp\": {\n        \"type\": \"datetime\",\n        \"lengthOrValues\": null,\n        \"default\": \"CURRENT_TIMESTAMP\",\n        \"allowNull\": true\n      },\n      \"exampleOneStringWithNull\": {\n        \"type\": \"varchar\",\n        \"lengthOrValues\": 50,\n        \"default\": null,\n        \"allowNull\": true\n      },\n      \"exampleOneStringWithoutNull\": {\n        \"type\": \"varchar\",\n        \"lengthOrValues\": 15,\n        \"default\": \"\",\n        \"allowNull\": false\n      },\n      \"exampleOneBigInt\": {\n        \"type\": \"bigint\",\n        \"lengthOrValues\": 20,\n        \"default\": null,\n        \"allowNull\": true\n      },\n      \"exampleOneText\": {\n        \"type\": \"text\",\n        \"lengthOrValues\": null,\n        \"default\": null,\n        \"allowNull\": true\n      }\n    },\n    \"indexes\": [\n      {\n        \"attribute\": \"exampleOneBigInt\",\n        \"indexName\": \"exampleEntityOne_exampleOneBigInt\",\n        \"indexChoice\": \"index\",\n        \"type\": \"BTREE\"\n      },\n      {\n        \"attribute\": \"exampleOneStringWithoutNull\",\n        \"indexName\": \"exampleEntityOne_exampleOneStringWithoutNull\",\n        \"indexChoice\": \"unique\",\n        \"type\": \"BTREE\"\n      },\n      {\n        \"attribute\": \"exampleOneText\",\n        \"indexName\": \"exampleEntityOne_exampleOneText\",\n        \"indexChoice\": \"fulltext\",\n        \"type\": \"BTREE\"\n      }\n    ],\n    \"relationships\": {\n    },\n    \"options\": {\n      \"enforceLockingConstraints\": true,\n      \"isAuditEnabled\": true\n    }\n  },\n  \"exampleEntityTwo\": {\n    \"module\": \"main\",\n    \"attributes\": {\n      \"exampleTwoTimeStamp\": {\n        \"type\": \"datetime\",\n        \"lengthOrValues\": null,\n        \"default\": \"CURRENT_TIMESTAMP\",\n        \"allowNull\": true\n      },\n      \"exampleTwoStringWithNull\": {\n        \"type\": \"varchar\",\n        \"lengthOrValues\": 50,\n        \"default\": null,\n        \"allowNull\": true\n      },\n      \"exampleTwoStringWithoutNull\": {\n        \"type\": \"varchar\",\n        \"lengthOrValues\": 15,\n        \"default\": null,\n        \"allowNull\": false\n      },\n      \"exampleTwoBigInt\": {\n        \"type\": \"bigint\",\n        \"lengthOrValues\": 20,\n        \"default\": null,\n        \"allowNull\": true\n      },\n      \"exampleTwoText\": {\n        \"type\": \"text\",\n        \"lengthOrValues\": null,\n        \"default\": null,\n        \"allowNull\": true\n      }\n    },\n    \"indexes\": [\n      {\n        \"attribute\": \"exampleTwoBigInt\",\n        \"indexName\": \"exampleEntityTwo_exampleTwoBigInt\",\n        \"indexChoice\": \"index\",\n        \"type\": \"BTREE\"\n      }\n    ],\n    \"relationships\": {\n      \"exampleEntityOne\":[\n        \"relationshipOne\",\n        \"relationshipTwo\"\n      ]\n    },\n    \"options\": {\n      \"enforceLockingConstraints\": false,\n      \"isAuditEnabled\": true\n    }\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdivbloxjs%2Fdx-db-sync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdivbloxjs%2Fdx-db-sync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdivbloxjs%2Fdx-db-sync/lists"}