{"id":20420948,"url":"https://github.com/moll/js-ddl","last_synced_at":"2026-03-09T15:31:20.559Z","repository":{"id":11000387,"uuid":"13323241","full_name":"moll/js-ddl","owner":"moll","description":"Gets you a JSON Schema from PostgreSQL or SQLite3. Also supports arrays and default values. Use it for introspection or preparing your domain models like with Rails's Active Record.","archived":false,"fork":false,"pushed_at":"2018-01-22T22:35:29.000Z","size":75,"stargazers_count":68,"open_issues_count":0,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-11-23T20:20:11.224Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/moll.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-04T12:04:15.000Z","updated_at":"2024-06-27T18:33:34.000Z","dependencies_parsed_at":"2022-08-30T04:00:53.056Z","dependency_job_id":null,"html_url":"https://github.com/moll/js-ddl","commit_stats":null,"previous_names":["moll/node-attributes"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/moll/js-ddl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moll%2Fjs-ddl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moll%2Fjs-ddl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moll%2Fjs-ddl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moll%2Fjs-ddl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moll","download_url":"https://codeload.github.com/moll/js-ddl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moll%2Fjs-ddl/sbom","scorecard":{"id":657712,"data":{"date":"2025-08-11","repo":{"name":"github.com/moll/js-ddl","commit":"462809899e39c806c593056018b5ac24c0103666"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Code-Review","score":0,"reason":"Found 1/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":9,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Warn: project license file does not contain an FSF or OSI license."],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 1 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-21T15:08:21.149Z","repository_id":11000387,"created_at":"2025-08-21T15:08:21.149Z","updated_at":"2025-08-21T15:08:21.149Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30301109,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T14:33:48.460Z","status":"ssl_error","status_checked_at":"2026-03-09T14:33:48.027Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2024-11-15T06:44:48.467Z","updated_at":"2026-03-09T15:31:20.533Z","avatar_url":"https://github.com/moll.png","language":"JavaScript","funding_links":[],"categories":["JSON Schema Tools"],"sub_categories":[],"readme":"DDL.js\n======\n[![NPM version][npm-badge]](http://badge.fury.io/js/ddl)\n\nDDL.js is a library that queries database and table schemas (currently from\n**PostgreSQL** and **SQLite3**) and describes their columns with [JSON\nSchema][jsonschema] v4.\n\nYou can use DDL.js for **introspection**, to **prepare your domain models** and\nset up **simple type coercions or validations** for those database columns.\nThis way you can have the same convenience that Ruby on Rails's ActiveRecord\nprovides, but in the JavaScript world.\n\nDDL.js is open for extension and modifications, so if you have suggestions what\nmore it should define or query from the database, please ping me with an\n[email][email], a [tweet][twitter] or [create an issue][issues] on GitHub.\n\n[npm-badge]: https://badge.fury.io/js/ddl.png\n[jsonschema]: http://json-schema.org\n[soul.js]: https://github.com/moll/js-soul\n\n\nInstalling\n----------\n```sh\nnpm install ddl\n```\n\nDDL.js follows [semantic versioning](http://semver.org/), so feel free to depend\non its major version with something like `\u003e= 1.0.0 \u003c 2` (a.k.a `^1.0.0`).\n\n\nUsing\n-----\nEach database has its own function you can call passing it the connection to\nthat database and the table name you'd like to get a data definition for. Look\nat [DDL.js API Documentation][api] for a list of supported databases.\n\nGiven the following table:\n```sql\nCREATE TABLE \"golfers\" (\n  \"name\" VARCHAR(255) DEFAULT 'Tiger' NOT NULL,\n  \"handicap\" INTEGER DEFAULT 52 NOT NULL,\n  \"updated_at\" DATETIME\n)\n```\n\nAnd the following code:\n```javascript\nvar Pg = require(\"pg\")\n\nvar db = new Pg.Client\ndb.connect({database: \"golf\"})\n\nvar Ddl = require(\"ddl\")\nDdl.postgresql(db, \"golfers\", function(err, ddl) {})\n```\n\nYour callback will be called with the following object for `ddl`:\n```javascript\n{\n  name: {type: \"string\", default: \"Tiger\", maxLength: 255},\n  handicap: {type: \"integer\", default: 52},\n  updated_at: {type: [\"string\", \"null\"], default: null}\n}\n```\n\nThis works well if you have a single JavaScript \"class\" or model per database\ntable. With DDL.js you can initialize that model's attributes and their\ndefault values without having to manually keep the database and the model\ndeclaration in sync.\n\nIf you want to use the returned definition with a JSON Schema validator library,\nuse it like this:\n\n```javascript\nvar Jsck = require(\"jsck\")\nvar ddl = Ddl.postgresqlSync(db, \"golfers\")\nvar validation = new Jsck.draft4({type: \"object\", properties: ddl})\nvalidation.validate({name: \"John\", handicap: 13})\n```\n\n\nAPI\n---\nFor extended documentation on all functions, please see the\n[DDL.js API Documentation][api].\n\n[api]: https://github.com/moll/js-ddl/blob/master/doc/API.md\n\n### [Ddl](https://github.com/moll/js-ddl/blob/master/doc/API.md#Ddl)\n- [postgresql](https://github.com/moll/js-ddl/blob/master/doc/API.md#Ddl.postgresql)(connection, tableName, callback)\n- [postgresqlSync](https://github.com/moll/js-ddl/blob/master/doc/API.md#Ddl.postgresqlSync)(connection, tableName)\n- [sqlite3](https://github.com/moll/js-ddl/blob/master/doc/API.md#Ddl.sqlite3)(connection, tableName, callback)\n\n### [Attribute](https://github.com/moll/js-ddl/blob/master/doc/API.md#Attribute)\n- [default](https://github.com/moll/js-ddl/blob/master/doc/API.md#attribute.default)\n- [maxLength](https://github.com/moll/js-ddl/blob/master/doc/API.md#attribute.maxLength)\n- [type](https://github.com/moll/js-ddl/blob/master/doc/API.md#attribute.type)\n\n\nLicense\n-------\nDDL.js is released under a *Lesser GNU Affero General Public License*, which in\nsummary means:\n\n- You **can** use this program for **no cost**.\n- You **can** use this program for **both personal and commercial reasons**.\n- You **do not have to share your own program's code** which uses this program.\n- You **have to share modifications** (e.g bug-fixes) you've made to this\n  program.\n\nFor more convoluted language, see the `LICENSE` file.\n\n\nAbout\n-----\n**[Andri Möll][moll]** typed this and the code.  \n[Monday Calendar][monday] supported the engineering work.\n\nIf you find DDL.js needs improving, please don't hesitate to type to me now\nat [andri@dot.ee][email] or [create an issue online][issues].\n\n[email]: mailto:andri@dot.ee\n[issues]: https://github.com/moll/js-ddl/issues\n[moll]: http://themoll.com\n[monday]: https://mondayapp.com\n[twitter]: https://twitter.com/theml\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoll%2Fjs-ddl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoll%2Fjs-ddl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoll%2Fjs-ddl/lists"}