{ "_args": [ [ { "raw": "websql@https://github.com/expo/node-websql/archive/18.0.0.tar.gz", "scope": null, "escapedName": "websql", "name": "websql", "rawSpec": "https://github.com/expo/node-websql/archive/18.0.0.tar.gz", "spec": "https://github.com/expo/node-websql/archive/18.0.0.tar.gz", "type": "remote" }, "/home/jdaugherty/work/GT2/GT2-Android/node_modules/expo" ] ], "_from": "https://github.com/expo/node-websql/archive/18.0.0.tar.gz", "_id": "websql@0.4.4", "_inCache": true, "_location": "/websql", "_phantomChildren": {}, "_requested": { "raw": "websql@https://github.com/expo/node-websql/archive/18.0.0.tar.gz", "scope": null, "escapedName": "websql", "name": "websql", "rawSpec": "https://github.com/expo/node-websql/archive/18.0.0.tar.gz", "spec": "https://github.com/expo/node-websql/archive/18.0.0.tar.gz", "type": "remote" }, "_requiredBy": [ "/expo" ], "_resolved": "https://github.com/expo/node-websql/archive/18.0.0.tar.gz", "_shasum": "39b12a08b0180495de1412d8a64a529e21ad554e", "_shrinkwrap": null, "_spec": "websql@https://github.com/expo/node-websql/archive/18.0.0.tar.gz", "_where": "/home/jdaugherty/work/GT2/GT2-Android/node_modules/expo", "author": { "name": "Nolan Lawson", "email": "nolan@nolanlawson.com" }, "browser": { "lib/index.js": "lib/browser.js", "crypto": false, "fs": false, "levelup": false, "leveldown": false, "level": false, "rimraf": false, "mkdirp": false }, "bugs": { "url": "https://github.com/nolanlawson/node-websql/issues" }, "dependencies": { "argsarray": "^0.0.1", "immediate": "^3.2.2", "noop-fn": "^1.0.0", "pouchdb-collections": "^1.0.1", "tiny-queue": "^0.2.1" }, "description": "WebSQL Database API, implemented for Node using sqlite3", "devDependencies": { "assert": "1.3.0", "bluebird": "3.3.5", "chai": "3.5.0", "chai-as-promised": "5.3.0", "denodeify": "1.2.1", "double-ended-queue": "2.1.0-0", "istanbul": "0.4.3", "istanbul-coveralls": "1.0.3", "js-extend": "1.0.1", "jshint": "2.8.0", "level-write-stream": "1.0.0", "levelup": "1.3.1", "lie": "3.0.2", "mkdirp": "0.5.1", "mocha": "2.4.5", "phantomjs-prebuilt": "2.1.7", "pouchdb-collate": "1.2.0", "rimraf": "2.5.2", "scope-eval": "0.0.3", "spark-md5": "2.0.2", "sublevel-pouchdb": "1.0.0", "vuvuzela": "1.0.3", "zuul": "3.10.1" }, "files": [ "lib", "custom" ], "homepage": "https://github.com/nolanlawson/node-websql#readme", "keywords": [ "websql", "sql", "opendatabase", "sqlite", "storage", "sqlite3", "database" ], "license": "Apache-2.0", "main": "lib/index.js", "name": "websql", "optionalDependencies": {}, "readme": "NOTE: This is [Expo](http://expo.io)'s fork without the `'sqlite3'` dependency which is unused in React Native.\n\nnode-websql [![Build Status](https://travis-ci.org/nolanlawson/node-websql.svg?branch=master)](https://travis-ci.org/nolanlawson/node-websql) [![Coverage Status](https://coveralls.io/repos/github/nolanlawson/node-websql/badge.svg?branch=master&nonce=foo)](https://coveralls.io/github/nolanlawson/node-websql?branch=master)\n====\n\nThe [WebSQL Database API][websql], implemented for Node\nusing [sqlite3](https://github.com/mapbox/node-sqlite3). In the browser, it falls back to `window.openDatabase`.\n\nInstall\n----\n\n npm install websql\n\nUsage\n----\n\n```js\nvar openDatabase = require('websql');\n```\n\nCreate a SQLite3 database called `mydb.db`:\n\n```js\nvar db = openDatabase('mydb.db', '1.0', 'description', 1);\n```\n\nCreate an in-memory database:\n\n```js\nvar db = openDatabase(':memory:', '1.0', 'description', 1);\n```\n\nAPI\n---\n\n### openDatabase(name, version, description, size [, callback])\n\nThe `name` is the name of the database. It's passed verbatim to [sqlite3][].\n\nThe `version` is the database version (_currently ignored - see below_).\n\nThe `description` and `size` attributes are ignored, but they are required for\ncompatibility with the WebSQL API.\n\nThe `callback` just returns the same database object returned\nsynchronously (_migrations currently aren't supported - see below_).\n\nFor more information how to use the WebSQL API, see [the spec][websql] or\n[various](http://www.html5rocks.com/en/tutorials/webdatabase/todo/) [tutorials](html5doctor.com/introducing-web-sql-databases/).\n\nFor more information on `sqlite3`, see [the SQLite3 readme](sqlite3).\n\n### In the browser\n\nYou can also use this module in the browser (via Browserify/Webpack/etc.),\nin which case it will just use\n`window.openDatabase`, meaning you are subject to [browser WebSQL support](http://caniuse.com/#feat=sql-storage).\n\n### readTransaction() vs transaction()\n\nBoth `readTransaction()` (read-only) and `transaction()` (read-write) are supported.\n`readTransaction()` has some small performance optimizations, so it's worthwhile to\nuse if you're not writing any data in a transaction.\n\nGoals\n----\n\nThe [WebSQL Database API][websql] is a deprecated\nstandard, but in many cases it's useful to reuse legacy code\ndesigned for browsers that support WebSQL. Also, it allows you to quickly\ntest WebSQL-based code in Node, which can be convenient.\n\nThe goal of this API is to exactly match the existing WebSQL API, as implemented\nin browsers. If there's any difference between browsers (e.g. `rows[0]` is supported\nin Chrome, whereas only `rows.item(0)` is supported in Safari), then the lowest-common\ndenominator version is exported by this library.\n\nThis library has a robust test suite, and has been known to pass the PouchDB\ntest suite as well.\n\nNon-Goals\n---\n\nThis library is _not_ designed to:\n\n- Invent new APIs, e.g. deleting databases, supporting `BLOB`s, encryption, etc.\n- Support WebSQL in Firefox, IE, or other non-WebSQL browsers\n\nIn other words, the goal is not to carry the torch of WebSQL,\nbut rather to bridge the gap from existing WebSQL-based code to Node.js.\n\nCustom SQLite3 bindings\n----\n\nThis library is designed to allow swappable SQLite3 implementations, beyond\njust [node-sqlite3](https://github.com/mapbox/node-sqlite3). Examples:\n\n* [node-websql itself](https://github.com/nolanlawson/node-websql/blob/7c6327c2bbcf48bb0ac26f8f689206b7227baf81/lib/sqlite/SQLiteDatabase.js)\n* [Cordova SQLite Plugin 2](https://github.com/nolanlawson/cordova-plugin-sqlite-2/blob/6bc32a4e71a3eea28fbc98c4da7e87c56156d094/src/javascript/SQLiteDatabase.js)\n* [React Native SQLite 2](https://github.com/noradaiko/react-native-sqlite-2)\n\nTo create your own custom implementation, use this API:\n\n```js\nvar customOpenDatabase = require('websql/custom');\nvar openDatabase = customOpenDatabase(SQLiteDatabase);\n```\n\nThis `SQLiteDatabase` implementation needs to be a constructor-style function\nwith a constructor signature like so:\n\n```js\n// takes a single argument: the database name\nvar db = new SQLiteDatabase('dbname');\n```\n\nThen it implements a single function, `exec()`, like so:\n\n```js\nfunction exec(queries, readOnly, callback) {\n // queries: an array of SQL statements and queries, with a key \"sql\" and \"args\"\n // readOnly: whether or not these queries are in \"read only\" mode\n // callback: callback to be called with results (first arg is error, second arg is results)\n}\n```\n\nHere is the full specification:\n\n### SQLiteDatabase(name (String))\n\nConstruct a new `SQLiteDatbase` object, with the given string name.\n\n### exec(queries (Array), readOnly (boolean), callback (function))\n\nExecute the list of `SQLQuery`s. If we are in `readOnly` mode, then any\nnon-`SELECT` queries need to throw an error without executing. This function calls the Node-style\ncallback with an error as the first argument or the `Array` as\nthe second argument.\n\n### SQLQuery\n\nA SQL query and bindings to execute. This can be a plain JavaScript object or a custom class,\nas long as it has the following members:\n\n#### sql (String)\n\nThe SQL query to execute.\n\n#### args (Array)\n\nThe arguments to bind the query.\n\nE.g.:\n\n```js\n{\n sql: 'INSERT INTO foo values (?, ?)',\n args: ['bar', 'baz']\n}\n```\n\n### SQLResult\n\nA result returned by a SQL query. This can be a plain JavaScript object or a custom class,\nas long as it has the following members:\n\n#### error\n\nA JavaScript `Error` object, or `undefined` if the `SQLQuery` did not throw an error. If `error` is truthy, then it's assumed `insertId`, `rowsAffected`, and `rows` are falsy (they will be ignored anyway).\n\n#### insertId (number)\n\nAn insertion ID representing the new row number, or `undefined` if nothing was inserted.\n\n#### rowsAffected (number)\n\nThe number of rows affected by the query, or 0 if none.\n\n#### rows (Array<object>)\n\nThe rows returned by a `SELECT` query, or empty if none.\n\nEach object is a mapping of keys (columns) to values (value fetched).\n\nE.g.:\n\n```js\n{\n insertId: undefined,\n rowsAffected: 0,\n rows: [\n {'foo': 'bar'},\n {'foo': 'baz'},\n ]\n}\n```\n\nOr:\n\n```js\n{\n error: new Error('whoopsie')\n}\n```\n\nFor an example implementation (and the one used by this module)\nsee `lib/sqlite/SQLiteDatabase.js`.\n\nTODOs\n---\n\nThe versioning and migration APIs\n(i.e. [`changeVersion()`](https://www.w3.org/TR/webdatabase/#dom-database-changeversion))\nare not supported. Pull requests welcome!\n\nLimitations\n----\n\n1. With the restrictions of the [node-sqlite3 API](https://github.com/mapbox/node-sqlite3/wiki/API)\non database names (\"Valid values are filenames, \":memory:\" for an anonymous\nin-memory database and an empty string for an anonymous disk-based\ndatabase\") and our lack of interest to enforce a particular mapping that\nhonors the [WebSQL spec](https://www.w3.org/TR/webdatabase/#dom-opendatabase)\nin its indicating that \"All strings including the empty string are valid database\nnames\" (and that they are case-sensitive), consumers will need to do their\nown mapping for strings in order to 1) avoid problems with invalid filenames or\nfilenames on case insensitive file systems, and to 2) avoid user databases being\ngiven special treatment if the empty string or the string \":memory:\" is used;\nanother special purpose form of string supported by SQLite that may call for\nescaping are [`file::memory:...`](https://sqlite.org/inmemorydb.html)\n[URLs](https://sqlite.org/uri.html#uri_format).\n\n2. Although neither the WebSQL spec nor SQLite speaks to this matter,\n`node-sqlite3` has the following additional\n[limitations](https://github.com/mapbox/node-sqlite3/wiki/API#databaseexecsql-callback)\nwhich are surfaced for our users: namely, that statements will only be\nexecuted up to the first NULL byte and [SQL comments](https://sqlite.org/lang_comment.html)\nwill lead to runtime errors.\n\nTesting\n----\n\nFirst:\n\n npm install\n\nMain test suite:\n\n npm test\n\nLinter:\n\n npm run lint\n\nTest in debug mode (e.g. with the `node-inspector`):\n\n npm run test-debug\n\nRun the test suite against actual WebSQL in a browser:\n\n npm run test-local\n\nRun the actual-WebSQL test against PhantomJS:\n\n npm run test-phantom\n\n[websql]: https://www.w3.org/TR/webdatabase/\n[sqlite3]: https://github.com/mapbox/node-sqlite3\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git://github.com/nolanlawson/node-websql.git" }, "scripts": { "coverage": "npm run test-coverage && npm run ensure-coverage", "ensure-coverage": "istanbul check-coverage --lines 100 --function 100 --statements 100 --branches 100", "lint": "jshint -c .jshintrc lib test", "report-coverage": "npm run test-coverage && istanbul-coveralls --no-rm", "test": "mocha test/test.js", "test-coverage": "istanbul cover ./node_modules/mocha/bin/_mocha -- test/test.js", "test-debug": "mocha --debug-brk test/test.js", "test-local": "zuul --no-coverage --local 9000 --ui mocha-bdd test/test.js", "test-phantom": "zuul --no-coverage --phantom --ui mocha-bdd test/test.js" }, "version": "0.4.4" }