{"id":20420917,"url":"https://github.com/moll/node-heaven-sqlite","last_synced_at":"2025-04-12T18:09:50.513Z","repository":{"id":57262253,"uuid":"183767214","full_name":"moll/node-heaven-sqlite","owner":"moll","description":"Heaven.js's Data Mapper for SQLite. CRUD API that parses and serializes your models to and from SQLite.","archived":false,"fork":false,"pushed_at":"2024-10-08T09:58:35.000Z","size":47,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T18:09:44.256Z","etag":null,"topics":["crud","data-mapper","heaven","sqlite"],"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":"2019-04-27T11:59:57.000Z","updated_at":"2024-12-18T12:01:40.000Z","dependencies_parsed_at":"2022-08-26T23:12:20.431Z","dependency_job_id":null,"html_url":"https://github.com/moll/node-heaven-sqlite","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moll%2Fnode-heaven-sqlite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moll%2Fnode-heaven-sqlite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moll%2Fnode-heaven-sqlite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moll%2Fnode-heaven-sqlite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moll","download_url":"https://codeload.github.com/moll/node-heaven-sqlite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248610338,"owners_count":21132921,"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":["crud","data-mapper","heaven","sqlite"],"created_at":"2024-11-15T06:44:40.813Z","updated_at":"2025-04-12T18:09:50.489Z","avatar_url":"https://github.com/moll.png","language":"JavaScript","readme":"Heaven.js for SQLite\n====================\n[![NPM version][npm-badge]](https://www.npmjs.com/package/heaven-sqlite)\n[![Build status][build-badge]](https://github.com/moll/node-heaven-sqlite/actions/workflows/node.yaml)\n\n**Heaven.js for SQLite** is a JavaScript library for Node.js that gives you a [CRUD][crud] API for your SQLite database by implementing a [Data Mapper][data-mapper] or [Table Data Gateway][table-data-gateway] object. It's built on [Heaven.js][heaven] and comes with adapters for [Mapbox's SQLite3][mapbox-sqlite3] and [Joshua Wise's Better SQLite3][better-sqlite3]. It'll also work with other SQLite libraries that have compatible APIs. Along with [Sqlate.js][sqlate]'s tagged template strings, this permits convenient SQL queries that get parsed to your models and equally easy creation and updating.\n\n[npm-badge]: https://img.shields.io/npm/v/heaven-sqlite.svg\n[build-badge]: https://github.com/moll/node-heaven-sqlite/actions/workflows/node.yaml/badge.svg\n[data-mapper]: https://www.martinfowler.com/eaaCatalog/dataMapper.html\n[table-data-gateway]: https://www.martinfowler.com/eaaCatalog/tableDataGateway.html\n[sqlate]: https://github.com/moll/js-sqlate\n[mapbox-sqlite3]: https://github.com/mapbox/node-sqlite3\n[better-sqlite3]: https://github.com/JoshuaWise/better-sqlite3\n[heaven]: https://github.com/moll/js-heaven\n[crud]: https://en.wikipedia.org/wiki/Create,_read,_update_and_delete\n\n\nInstalling\n----------\n```sh\nnpm install heaven-sqlite\n```\n\nHeaven.js for SQLite follows [semantic versioning](http://semver.org), so feel free to depend on its major version with something like `\u003e= 2 \u003c 3` (a.k.a `^2`).\n\n\nUsing with Mapbox's SQLite3\n---------------------------\nInstantiate `SqliteHeaven` by passing it the constructor for your model, an SQLite connection and a table name:\n\n```javascript\nvar SqliteHeaven = require(\"heaven-sqlite/mapbox\")\nvar Sqlite3 = require(\"sqlite3\")\nvar sqlite = new Sqlite3.Database(\":memory:\")\nsqlite.serialize()\n\nfunction Model(attrs) { Object.assign(this, attrs)}\nvar modelsDb = new SqliteHeaven(Model, sqlite, \"models\")\n```\n\nSuppose the \"models\" table looks like this:\n```sql\nCREATE TABLE \"models\" (\n  \"id\" INTEGER PRIMARY KEY NOT NULL,\n  \"name\" TEXT DEFAULT '',\n  \"age\" INTEGER DEFAULT 0\n)\n```\n\nYou can then call the five [CRUD][crud] methods like described in [Heaven.js's README][heaven]:\n\n```javascript\nvar sql = require(\"sqlate\")\n\nvar john = await modelsDb.create({name: \"John\", age: 13})\nvar mike = await modelsDb.create({name: \"Mike\", age: 42})\n\nmodelsDb.search(sql`SELECT * FROM models WHERE age \u003c 15`)\nmodelsDb.read(john.id)\nmodelsDb.update(model, {age: 42})\nmodelsDb.delete(model)\n```\n\n\nUsing with Joshua Wise's Better SQLite3\n---------------------------------------\nInstantiate `SqliteHeaven` by passing it the constructor for your model, an SQLite connection and a table name:\n\n```javascript\nvar SqliteHeaven = require(\"heaven-sqlite/better\")\nvar Sqlite3 = require(\"better-sqlite3\")\nvar sqlite = new Sqlite3.Database(\":memory:\", {memory: true})\n\nfunction Model(attrs) { Object.assign(this, attrs)}\nvar modelsDb = new SqliteHeaven(Model, sqlite, \"models\")\n```\n\nSuppose the \"models\" table looks like this:\n```sql\nCREATE TABLE \"models\" (\n  \"id\" INTEGER PRIMARY KEY NOT NULL,\n  \"name\" TEXT DEFAULT '',\n  \"age\" INTEGER DEFAULT 0\n)\n```\n\nYou can then call the five [CRUD][crud] methods like described in [Heaven.js's README][heaven], but compared to Mapbox's SQLite3, synchronously:\n\n```javascript\nvar sql = require(\"sqlate\")\n\nvar john = modelsDb.create({name: \"John\", age: 13})\nvar mike = modelsDb.create({name: \"Mike\", age: 42})\n\nmodelsDb.search(sql`SELECT * FROM models WHERE age \u003c 15`)\nmodelsDb.read(john.id)\nmodelsDb.update(model, {age: 42})\nmodelsDb.delete(model)\n```\n\n\nLicense\n-------\nHeaven.js for SQLite is released under a *Lesser GNU Affero General Public License*, which in summary 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 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 Heaven.js for SQLite needs improving, please don't hesitate to type to me now at [andri@dot.ee][email] or [create an issue online][issues].\n\n[email]: mailto:andri@dot.ee\n[issues]: https://github.com/moll/node-heaven-sqlite/issues\n[moll]: https://m811.com\n[monday]: https://mondayapp.com\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoll%2Fnode-heaven-sqlite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoll%2Fnode-heaven-sqlite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoll%2Fnode-heaven-sqlite/lists"}