{"id":13721041,"url":"https://github.com/walinejs/dittorm","last_synced_at":"2026-02-13T01:11:28.307Z","repository":{"id":37049402,"uuid":"462357169","full_name":"walinejs/dittorm","owner":"walinejs","description":"A Node.js ORM for MySQL, SQLite, PostgreSQL, MongoDB, GitHub and serverless service like Deta, InspireCloud, CloudBase, LeanCloud.","archived":false,"fork":false,"pushed_at":"2025-04-08T11:42:48.000Z","size":133,"stargazers_count":27,"open_issues_count":14,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-10T00:53:13.472Z","etag":null,"topics":["cloudbase","deta","github","inspirecloud","leancloud","mongodb","mysql","nodejs","orm","postgresql","serverless","sqlite"],"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/walinejs.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":"2022-02-22T15:25:07.000Z","updated_at":"2025-02-01T18:58:47.000Z","dependencies_parsed_at":"2024-01-06T01:03:47.961Z","dependency_job_id":"49183053-9ca5-4268-94cf-9e25042c7fb4","html_url":"https://github.com/walinejs/dittorm","commit_stats":null,"previous_names":["walinejs/ditto"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walinejs%2Fdittorm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walinejs%2Fdittorm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walinejs%2Fdittorm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walinejs%2Fdittorm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/walinejs","download_url":"https://codeload.github.com/walinejs/dittorm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137995,"owners_count":21053775,"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":["cloudbase","deta","github","inspirecloud","leancloud","mongodb","mysql","nodejs","orm","postgresql","serverless","sqlite"],"created_at":"2024-08-03T01:01:11.639Z","updated_at":"2026-02-13T01:11:28.250Z","avatar_url":"https://github.com/walinejs.png","language":"TypeScript","readme":"# Dittorm\n\nA Node.js ORM for MySQL, SQLite, PostgreSQL, MongoDB, GitHub and serverless service like Deta, InspireCloud, CloudBase, LeanCloud.\n\n## Installation\n\n```\nnpm install dittorm --save\n```\n\n## Quick Start\n\n```js\nconst Model = require('dittorm')('leancloud');\nconst userModel = new Model('user', {\n  appId: 'xxx',\n  appKey: 'xxx',\n  masterKey: 'xxx'\n});\n\nconst user = await userModel.add({\n  username: 'lizheming',\n  email: 'i@imnerd.org'\n});\n\nconst findUser = await user.select({email: 'i@imnerd.org'});\n```\n\n## Documentation\n\n### Configuration\n\n#### LeanCloud\n\n```js\nconst Model = require('dittorm')('leancloud');\nconst userModel = new Model('user', {\n  appId: 'xxx',\n  appKey: 'xxx',\n  masterKey: 'xxx'\n});\n```\n\n| Name        | Required | Default | Description |\n| ----------- | -------- | ------- | ----------- |\n| `appId`     | ✅        |         |             |\n| `appKey`    | ✅        |         |             |\n| `masterKey` | ✅        |         |             |\n\n#### Deta\n\n```js\nconst Model = require('dittorm')('deta');\nconst userModel = new Model('user', {\n  token: 'xxx'\n});\n```\n\n\n| Name    | Required | Default | Description             |\n| ------- | -------- | ------- | ----------------------- |\n| `token` | ✅        |         | Deta project secret key |\n\n#### InspireCloud\n\n```js\nconst Model = require('dittorm')('inspirecloud');\nconst userModel = new Model('user', {\n  serviceId: 'xxx',\n  serviceSecret: 'xxx'\n});\n```\n\n| Name            | Required | Default | Description                 |\n| --------------- | -------- | ------- | --------------------------- |\n| `serviceId`     | ✅        |         | InspireCloud Service ID     |\n| `serviceSecret` | ✅        |         | InspireCloud Service Secret |\n#### CloudBase\n\n```js\nconst Model = require('dittorm')('cloudbase');\nconst userModel = new Model('user', {\n  env: 'xxx',\n  secretId: 'xxx',\n  secretKey: 'xxx'\n})\n```\n\n| Name        | Required | Default | Description                                                                              |\n| ----------- | -------- | ------- | ---------------------------------------------------------------------------------------- |\n| `env`       | ✅        |         | CloudBase enviroment ID                                                                  |\n| `secretId`  | ✅        |         | CloudBase API secret Id, apply it at [here](https://console.cloud.tencent.com/cam/capi)  |\n| `secretKey` | ✅        |         | CloudBase API secret Key, apply it at [here](https://console.cloud.tencent.com/cam/capi) |\n\n#### GitHub\n\n```js\nconst Model = require('dittorm')('github');\nconst userModel = new Model('user', {\n  token: 'xxx',\n  repo: 'xxx',\n  path: 'xxx',\n})\n```\n\n| Name  | Required | Default | Description                                                                                                      |\n| ----- | -------- | ------- | ---------------------------------------------------------------------------------------------------------------- |\n| token | ✅        |         | [Personal access tokens](https://github.com/settings/tokens)                                                     |\n| repo  | ✅        |         | repository name, such as `walinejs/dittorm`                                                                      |\n| path  |          |         | The data storage directory, such as `data` means it is stored in the `data` directory, root directory by default |\n\n\n#### MySQL\n\n```js\nconst Model = require('dittorm')('mysql');\nconst userModel = new Model('user', {\n  host: '127.0.0.1',\n  port: 3306,\n  database: 'blog',\n  user: 'admin',\n  password: 'admin',\n  prefix: 'dt_',\n  charset: 'utf8mb4',\n  dateString: true\n})\n```\n\n| Name       | Required | Default   | Description           |\n| ---------- | -------- | --------- | --------------------- |\n| `host`     |          | 127.0.0.1 | MySQL server address  |\n| `port`     |          | 3306      | MySQL server port     |\n| `database` | ✅        |           | MySQL database name   |\n| `user`     | ✅        |           | MySQL server username |\n| `password` | ✅        |           | MySQL server password |\n| `prefix`   |          |           | MySQL table prefix    |\n| `charset`  |          |           | MySQL table charset   |\n\n#### SQLite\n\n\n| Name       | Required | Default | Description                                                         |\n| ---------- | -------- | ------- | ------------------------------------------------------------------- |\n| `path`     | ✅        |         | SQLite storage file path, not include file name                     |\n| `database` |          |         | SQLite storage file name, change it if your filenamed is not waline |\n| `prefix`   |          |         | SQLite table prefix                                                 |\n#### PostgreSQL\n\n```js\nconst Model = require('dittorm')('postgresql');\nconst userModel = new Model('user', {\n  host: '127.0.0.1',\n  port: 5432,\n  database: 'blog',\n  user: 'admin',\n  password: 'admin',\n  prefix: 'dt_',\n  connectionLimit: 1,\n})\n```\n\n| Name       | Required | Default   | Description                |\n| ---------- | -------- | --------- | -------------------------- |\n| `host`     |          | 127.0.0.1 | PostgreSQL server address  |\n| `port`     |          | 3211      | PostgreSQL server port     |\n| `database` | ✅        |           | PostgreSQL database name   |\n| `user`     | ✅        |           | PostgreSQL server username |\n| `password` | ✅        |           | PostgreSQL server password |\n| `prefix`   |          |           | PostgreSQL table prefix    |\n#### MongoDB\n\n```js\nconst Model = require('dittorm')('mongodb');\nconst userModel = new Model('user', {\n  host: '127.0.0.1',\n  port: 27017,\n  database: 'blog',\n  user: 'admin',\n  password: 'admin',\n  options: {\n    replicaset: 'xxx',\n    authSource: 'admin',\n    ssl: true\n  }\n});\n```\n\n| Name          | Required | Default   | Description                                  |\n| ------------- | -------- | --------- | -------------------------------------------- |\n| `host`        |          | 127.0.0.1 | MongoDB server address, support array format |\n| `port`        |          | 27017     | MongoDB server port, support array format    |\n| `database`    | ✅        |           | MongoDB database name                        |\n| `user`        | ✅        |           | MongoDB server username                      |\n| `password`    | ✅        |           | MongoDB server password                      |\n| `replicaset`  |          |           | MongoDB replica set                          |\n| `authSourcce` |          |           | MongoDB auth source                          |\n| `ssl`         |          |           | use SSL connection                           |\n### API\n\n#### add(data)\n\nSave store data.\n\n```js\nconst data = await userModel.add({ username: 'lizheming', email: 'i@imnerd.org' });\nconsole.log(data.id);\n```\n#### select(where, options)\n\nFind store data by condition.\n\n```js\n// SELECT * FROM user WHERE username = 'lizheming';\nconst data = await userModel.select({ username: 'lizheming' });\n\n// SELECT email FROM user WHERE username = 'lizheming' ORDER BY email DESC LIMIT 1 OFFSET 1;\nconst data = await userModel.select({ username: 'lizheming' }, {\n  field: ['email'],\n  desc: 'email',\n  limit: 1,\n  offset: 1\n});\n\n// SELECT * FROM user WHERE username != 'lizheming';\nconst data = await userModel.select({ username: ['!=', 'lizheming'] });\n\n// SELECT * FROM user WHERE create_time \u003e '2022-01-01 00:00:00';\nconst data = await userModel.select({ username: ['\u003e', '2022-01-01 00:00:00'] });\n\n// SELECT * FROM user WHERE username IN ('lizheming', 'michael');\nconst data = await userModel.select({ username: ['IN', ['lizheming', 'michael']] });\n\n// SELECT * FROM user WHERE username NOT IN ('lizheming', 'michael');\nconst data = await userModel.select({ username: ['NOT IN', ['lizheming', 'michael']] });\n\n// SELECT * FROM user WHERE username LIKE '%li%';\nconst data = await userModel.select({ username: ['LIKE', '%li%'] });\n\n// SELECT * FROM user WHERE username = 'lizheming' AND create_time \u003e '2022-01-01 00:00:00';\nconst data = await userModel.select({ \n  username: 'lizheming',\n  create_time: ['\u003e', '2022-01-01 00:00:00'] \n});\n\n// SELECT * FROM user WHERE username = 'lizheming' OR create_time \u003e '2022-01-01 00:00:00';\nconst data = await userModel.select({\n  _complex: { \n    username: 'lizheming',\n    create_time: ['\u003e', '2022-01-01 00:00:00'],\n    _logic: 'OR'\n  }\n});\n```\n#### update(data, where)\n \nUpdate store data by condition. `where` format same as `select(where, options)`.\n#### count(where)\n\nReturn store data count by condition. `where` format same as `select(where, options)`.\n#### delete(where)\n\nClean store data by condition. `where` format same as `select(where, options)`.\n","funding_links":[],"categories":["ORM's"],"sub_categories":["JavaScript ORM"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwalinejs%2Fdittorm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwalinejs%2Fdittorm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwalinejs%2Fdittorm/lists"}