{"_id":"@6river/sqlite","_rev":"5-ab35bb519585d9c4bf3b0c8da339e2bc","name":"@6river/sqlite","dist-tags":{"latest":"3.0.3"},"versions":{"3.0.3":{"name":"@6river/sqlite","version":"3.0.3","description":"SQLite client for Node.js applications with SQL-based migrations API","repository":{"type":"git","url":"git+https://github.com/kriasoft/node-sqlite.git"},"author":{"name":"Kriasoft","email":"hello@kriasoft.com","url":"https://www.kriasoft.com"},"contributors":[{"name":"Konstantin Tarkus","email":"hello@tarkus.me","url":"https://twitter.com/koistya"},{"name":"Theo Gravity","email":"theo@suteki.nu","url":"https://www.npmjs.com/~theo.gravity"}],"keywords":["sqlite","db","database","sql","migrate","migration","migrations","migrator","seed","seeds","seeder","node","node5","babel","es6","async","promise","promises","api"],"license":"MIT","main":"main.js","jsnext:main":"main.mjs","types":"main.d.ts","babel":{"plugins":["transform-async-to-generator","transform-es2015-modules-commonjs"]},"eslintConfig":{"parser":"babel-eslint","extends":"airbnb-base","rules":{"no-restricted-syntax":"off","prefer-rest-params":"off","import/no-extraneous-dependencies":"off"}},"dependencies":{"@6river/sqlite3":"^4.0.0","sql-template-strings":"^2.2.2"},"devDependencies":{"babel-cli":"^6.22.2","babel-eslint":"^7.1.1","babel-plugin-external-helpers":"^6.22.0","babel-plugin-transform-async-to-generator":"^6.22.0","babel-plugin-transform-es2015-modules-commonjs":"^6.22.0","babel-preset-es2015":"^6.22.0","chai":"^3.5.0","del":"^2.2.2","eslint":"^3.14.1","eslint-config-airbnb-base":"^11.0.1","eslint-plugin-import":"^2.2.0","mocha":"^5.2.0","rollup":"^0.41.4","rollup-plugin-babel":"^2.7.1"},"optionalDependencies":{"sql-template-strings":"^2.2.2"},"scripts":{"lint":"eslint src test tools","test":"node tools/build && mocha","build":"node tools/build"},"gitHead":"4954b9fe516d3044d3e27d2141b7b75746c9db0f","bugs":{"url":"https://github.com/kriasoft/node-sqlite/issues"},"homepage":"https://github.com/kriasoft/node-sqlite#readme","_id":"@6river/sqlite@3.0.3","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"6river-machine","email":"swdev@6river.com"},"dist":{"integrity":"sha512-rAb3nqKkFvnVSl7G5FbCgFudvKNhieZVhSfMP5S4SAc++yy1EqnyM2/T2FV8qi+nFxe7VQ1jpRMIe1RapXNHng==","shasum":"d84b0fb235cca19dec7aa21ef2020e96d251b1cd","tarball":"https://registry.npmjs.org/@6river/sqlite/-/sqlite-3.0.3.tgz","fileCount":23,"unpackedSize":138745,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdkWCzCRA9TVsSAnZWagAAPgEQAIToFOzxRUQdaWKQuqaF\nB79CYZzLK8DDZTUXJbXP6J59zkJezvy2WkXn6g/GX1425G4Qd6av3mhKiiv/\npAIw9Q9W3+eXC9wtiEhgZ4RVPZ4uMNDb3HLYQqNQN8h+zJmrmQQPB5ibbMZU\nNcV6vjyMooUTld1WXVtNvh5XLTYdvUWItn12k9Fz5h4YbSjH+SCFdqN2VKOf\nnuqjKu9CnExujQrIr1ZrjE1yoWN4sHnS8IyfONN9dhbegt6ROaxXv/NIIkVS\n1Fu6MHN/WSBfMJ4j6YTll8ZjLi94H/tfRz/huWBmxQxgfa5TX61AYC/fcbu+\n5pRyViGzLAoUFg5GGCqpyDIBs0j0KdKuBGbY2pJgghSnHXQHp3Q5OMjpPT8k\nGpnSiIxTyxJx8j08hi8abO8Ht26oDGNjWw+Q1v8MqttV5TVe9daC5RlSPzxX\nD2cMZ9vInLQXVjyvhcUDR8ewhMWwEN5gBMdeOGQH12RVn8eBM5gR7Pk3fMkQ\nGFBScNVPsyGjtQj7u7JmCpr/6rS75UX+klvSeLWf0D2EOQLDUMLaK+Hx6kdj\n2FlteaGwFMMuwXFXV5Y29V8p8bLCKKZjxzMnBGhmoijTwL/4rejWBHipD7Tw\nezZFsnevBozghFmUT0IiZQFWRW1LxY8+5HL8Mn3BWxdLCRpyrAfq7+Tf4wtl\nQffX\r\n=SRpc\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCk2BGyoVE2l0I6CKVCnlgovsh7H2ZWkxiNkEpuTPsXBQIgb8XT6QJmkLyE+ON2c3j6d0AEH90OFfwisPWaLROaeSQ="}]},"maintainers":[{"name":"6river-machine","email":"swdev@6river.com"},{"name":"c11k","email":"josh@c11k.org"},{"name":"kolach","email":"chikolad@gmail.com"},{"name":"jbcpollak","email":"josh@offthehill.org"},{"name":"jjhughes57","email":"jjhughes57@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sqlite_3.0.3_1569808563245_0.11949106742480486"},"_hasShrinkwrap":false}},"time":{"created":"2019-09-30T01:56:03.099Z","3.0.3":"2019-09-30T01:56:03.442Z","modified":"2023-01-05T17:02:47.811Z"},"maintainers":[{"email":"eng_sw_devops@6river.com","name":"6river-npm"},{"email":"swdev@6river.com","name":"6river-machine"},{"email":"chikolad@gmail.com","name":"kolach"},{"email":"jjhughes57@gmail.com","name":"jjhughes57"},{"email":"afrance@6river.com","name":"aaron.france"}],"description":"SQLite client for Node.js applications with SQL-based migrations API","homepage":"https://github.com/kriasoft/node-sqlite#readme","keywords":["sqlite","db","database","sql","migrate","migration","migrations","migrator","seed","seeds","seeder","node","node5","babel","es6","async","promise","promises","api"],"repository":{"type":"git","url":"git+https://github.com/kriasoft/node-sqlite.git"},"contributors":[{"name":"Konstantin Tarkus","email":"hello@tarkus.me","url":"https://twitter.com/koistya"},{"name":"Theo Gravity","email":"theo@suteki.nu","url":"https://www.npmjs.com/~theo.gravity"}],"author":{"name":"Kriasoft","email":"hello@kriasoft.com","url":"https://www.kriasoft.com"},"bugs":{"url":"https://github.com/kriasoft/node-sqlite/issues"},"license":"MIT","readme":"## SQLite Client for Node.js Apps\n\n[![NPM version](http://img.shields.io/npm/v/sqlite.svg?style=flat-square)](https://www.npmjs.com/package/sqlite)\n[![NPM downloads](http://img.shields.io/npm/dm/sqlite.svg?style=flat-square)](https://www.npmjs.com/package/sqlite)\n[![Build Status](http://img.shields.io/travis/kriasoft/node-sqlite/master.svg?style=flat-square)](https://travis-ci.org/kriasoft/node-sqlite)\n[![Dependency Status](http://img.shields.io/david/kriasoft/node-sqlite.svg?style=flat-square)](https://david-dm.org/kriasoft/node-sqlite)\n[![Online Chat](http://img.shields.io/badge/chat-%23node--sqlite_on_Gitter-blue.svg?style=flat-square)](https://gitter.im/kriasoft/node-sqlite)\n\n> A wrapper library that adds ES6 promises and SQL-based migrations API to\n> [sqlite3](https://github.com/mapbox/node-sqlite3/) ([docs](https://github.com/mapbox/node-sqlite3/wiki)).\n\n---\n\n<p align=\"center\"><b>🔥 Want to strengthen your core JavaScript skills and master ES6?</b><br>I would personally recommend this awesome <a href=\"https://es6.io/friend/konstantin\">ES6 course</a> by Wes Bos.</p>\n\n---\n\n\n### How to Install\n\n```sh\n$ npm install sqlite --save\n```\n\n\n### How to Use\n\n**NOTE**: For Node.js v5 and below use `var db = require('sqlite/legacy');`.\n\nThis module has the same API as the original `sqlite3` library ([docs](https://github.com/mapbox/node-sqlite3/wiki/API)),\nexcept that all its API methods return ES6 Promises and do not accept callback arguments.\n\nBelow is an example of how to use it with [Node.js](https://nodejs.org), [Express](http://expressjs.com/starter/hello-world.html) and [Babel](http://babeljs.io/):\n\n```js\nimport express from 'express';\nimport Promise from 'bluebird';\nimport sqlite from 'sqlite';\n\nconst app = express();\nconst port = process.env.PORT || 3000;\nconst dbPromise = sqlite.open('./database.sqlite', { Promise });\n\napp.get('/post/:id', async (req, res, next) => {\n  try {\n    const db = await dbPromise;\n    const [post, categories] = await Promise.all([\n      db.get('SELECT * FROM Post WHERE id = ?', req.params.id),\n      db.all('SELECT * FROM Category')\n    ]);\n    res.render('post', { post, categories });\n  } catch (err) {\n    next(err);\n  }\n});\n\napp.listen(port);\n```\n\n### ES6 tagged template strings\n\nThis module is compatible with [sql-template-strings](https://www.npmjs.com/package/sql-template-strings).\n\n```js\nimport SQL from 'sql-template-strings';\nimport sqlite from 'sqlite';\n\nconst db = await sqlite.open('./database.sqlite');\n\nconst book = 'harry potter';\nconst author = 'J. K. Rowling';\n\nconst data = await db.all(SQL`SELECT author FROM books WHERE name = ${book} AND author = ${author}`);\n```\n\n### Cached DB Driver\n\nIf you want to enable the [database object cache](https://github.com/mapbox/node-sqlite3/wiki/Caching)\n\n```js\nsqlite.open('./database.sqlite', { cached: true })\n```\n\n### Migrations\n\nThis module comes with a lightweight migrations API that works with [SQL-based migration files](https://github.com/kriasoft/node-sqlite/tree/master/migrations)\nas the following example demonstrates:\n\n##### `migrations/001-initial-schema.sql`\n\n```sql\n-- Up\nCREATE TABLE Category (id INTEGER PRIMARY KEY, name TEXT);\nCREATE TABLE Post (id INTEGER PRIMARY KEY, categoryId INTEGER, title TEXT,\n  CONSTRAINT Post_fk_categoryId FOREIGN KEY (categoryId)\n    REFERENCES Category (id) ON UPDATE CASCADE ON DELETE CASCADE);\nINSERT INTO Category (id, name) VALUES (1, 'Business');\nINSERT INTO Category (id, name) VALUES (2, 'Technology');\n\n-- Down\nDROP TABLE Category\nDROP TABLE Post;\n```\n\n##### `migrations/002-missing-index.sql`\n\n```sql\n-- Up\nCREATE INDEX Post_ix_categoryId ON Post (categoryId);\n\n-- Down\nDROP INDEX Post_ix_categoryId;\n```\n\n##### `app.js` (Node.js/Express)\n\n```js\nimport express from 'express';\nimport Promise from 'bluebird';\nimport sqlite from 'sqlite';\n\nconst app = express();\nconst port = process.env.PORT || 3000;\n\nconst dbPromise = Promise.resolve()\n  .then(() => sqlite.open('./database.sqlite', { Promise }))\n  .then(db => db.migrate({ force: 'last' }));\n\napp.use(/* app routes */);\n\napp.listen(port);\n```\n\n**NOTE**: For the development environment, while working on the database schema, you may want to set\n`force: 'last'` (default `false`) that will force the migration API to rollback and re-apply the\nlatest migration over again each time when Node.js app launches.\n\n\n### Multiple Connections\n\nThe `open` method resolves to the db instance which can be used in order to reference multiple open databases.\n\n#### ES6\n\n```js\nimport sqlite from 'sqlite';\n\nPromise.all([\n  sqlite.open('./main.sqlite', { Promise }),\n  sqlite.open('./users.sqlite', { Promise })\n]).then(function([mainDb, usersDb]){\n  ...\n});\n```\n\n#### ES7+ Async/Await\n\n```js\nimport sqlite from 'sqlite';\n\nasync function main() {\n  const [mainDb, usersDb] = await Promise.all([\n    sqlite.open('./main.sqlite', { Promise }),\n    sqlite.open('./users.sqlite', { Promise })\n  ]);\n  ...\n}\nmain();\n```\n\n### References\n\n* [Using SQLite with Node.js for Rapid Prototyping](https://medium.com/@tarkus/node-js-and-sqlite-for-rapid-prototyping-bc9cf1f26f10) on Medium.com\n* [SQLite Documentation](https://www.sqlite.org/docs.html), e.g. [SQL Syntax](https://www.sqlite.org/lang.html), [Data Types](https://www.sqlite.org/datatype3.html) etc. on SQLite.org\n* ES6 tagged [sql-template-strings](https://www.npmjs.com/package/sql-template-strings).\n\n\n### Related Projects\n\n* [Node.js API Starter](https://github.com/kriasoft/nodejs-api-starter) — Data API server boilerplate (Node.js, PostgreSQL, Redis, Passport.js and GraphQL)\n* [React Starter Kit](https://github.com/kriasoft/react-starter-kit) — Isomorphic web app boilerplate (Node.js/Express, React.js, GraphQL)\n* [ASP.NET Core Starter Kit](https://github.com/kriasoft/aspnet-starter-kit) — Single-page app boilerplate (ASP.NET Core, React.js, Web API)\n* [Babel Starter Kit](https://github.com/kriasoft/babel-starter-kit) — JavaScript library boilerplate (ES2015, Babel, Rollup)\n* [Membership Database](https://github.com/membership/membership.db) — SQL database boilerplate for web app users, roles and auth tokens\n\n\n### Support\n\n* Join [#node-sqlite](https://gitter.im/kriasoft/node-sqlite) chat room on Gitter to stay up to date regarding the project\n* Join [#sqlite](https://webchat.freenode.net/?channels=sql,sqlite) IRC chat room on Freenode about general discussion about SQLite\n\n\n### License\n\nThe MIT License © 2015-present Kriasoft. All rights reserved.\n\n---\nMade with ♥ by [Konstantin Tarkus](https://github.com/koistya) ([@koistya](https://twitter.com/koistya)), [Theo Gravity](https://github.com/theogravity) and [contributors](https://github.com/kriasoft/node-sqlite/graphs/contributors)\n","readmeFilename":"README.md"}