UNPKG

opendatabase

Version:

The WebSql standard for Nodejs using Sqlite3.

37 lines (36 loc) 4.53 kB
{ "version": "0.2.1", "license": "GNU v3", "engine": "node >= 0.6.0", "name": "opendatabase", "repository": { "type": "hg", "url": "http://bitbucket.org/surgemcgee/opendatabase/src/" }, "description": "The WebSql standard for Nodejs using Sqlite3.", "private": false, "homepage": "", "keywords": [ "websql", "opendatabase", "sqlite", "sqlite3", "transaction" ], "author": { "name": "Robert Edward Steckroth II", "url": "http://appmobile.in" }, "main": "./lib/openDatabase.js", "scripts": { "preinstall": "sh install_sqlite3_json.sh" }, "readmeFilename": "README.md", "readme": "#opendatabase\n### A WebSql standardized Sqlite3 wrapper for Nodejs\n\n[![NPM](https://nodei.co/npm/opendatabase.png?downloads=true)](https://nodei.co/npm/opendatabase/)\n\n**Author:** Robert Edward Steckroth II\n\n**Digital Persona:** Surgemcgee, Bustout <RobertSteckroth@gmail.com>\n\n**License:** GNU GENERAL PUBLIC LICENSE Version 3\n\n**Features:** \n\n* Modified Sqlite3 binaries to efficiently support this module\n* Low overhead (no regex or looping mechanisms are used).\n* Conforms to WebSql practices\n\n**Caveats:** \n\n1. SQLResultSet.rowsAffected is not integrated. \n2. Data type assignment is not supported. All \"?\" replacements will be inserted as a STRING into the database\n3. Synchronous database calls (Although the module utilizes asynchronous practice).\n4. Database init version and size attributes are superficial (not important).\n5. Only works on Linux varients (developed on Ubuntu)\n\n\n#####NOTE: opendatabase works the same way as WebSql. The WebSql documentation should be suitable to learn this module.\n\n\n**Description:** \n\nThis module conforms to the WebSql standard. However, some WebSql features are not integrated yet (see caveats above). A modified version of the Sqlite3 binaries is used to format json data and efficiently integrated into nodejs. Query results are stored statically into JavaScript objects and retrieved via object keys. The module has no dependencies other than the Sqlite3 binaries distributed with it. The ``install_sqlite3_json.sh`` script in the base directory compiles and install this module into the correct directory for use with the opendatabase module.\n\n```\n// Example opendatabase run through\n\nvar path = require('path'),\n opendatabase = require('opendatabase')\n\nvar database_dir = path.join(path.dirname(__filename), 'test_openDatabase.sqlite')\nvar open_db = new opendatabase({name: database_dir, version: \"1.0\", description: \"Example database for indurate.js\", size: 3*1024*1024})\n\n\nvar log = function(message) {\n console.log('[opendatabase test script] '+message)\n\n}\n\nvar err = function(tx, error) {\n console.log(error.message+'Code: '+error.code)\n // tx object is here as well\n log('inserting data into table from the error callback..')\n tx.executeSql('INSERT OR REPLACE INTO opendb_test VALUES(?, ?);', ['Column 1 text', 'Column 2 text'], function(tx, results) {\n log('Successfully inserted data with sql command --> '+results.rows.sql+'\\nResults length is '+results.rows.length)\n log('\\n\\n-- This should indicate that your opendatabase module is working correctly. --')\n }, err) // <-- !THIS WILL BE CALLED IN A INFINATE LOOP IF THE TX RETURNS AN ERROR\n\n}\n\n\nlog('Opening a new transaction..')\nopen_db.transaction(function(tx) {\n log('Creating a new table if not exists..')\n tx.executeSql('CREATE TABLE IF NOT EXISTS opendb_test(? TEXT UNIQUE, ? TEXT);', ['name', 'column_field'], function(tx, results) {\n log('Successfully created new table with sql command --> '+results.rows.sql+'\\nResults length is '+results.rows.length)\n log('Inserting a table with a bad sql command (syntax errors)..')\n tx.executeSql('INSERT OR REPdLACE INTO opendb_test VALUES(?, ?);', ['Column 1 text', 'Column 2 text'], function(tx, results) {\n log('This can\\'t happen because the command syntax is bad')\n }, err) // Call this due to syntax errors\n }, err)\n\n})\n\n```\n\n### The [Indurate.js](https://bitbucket.org/surgemcgee/indurate-database/src/) wrapper for opendatabase is the recomended way to manage your server/phonegap application database needs\n", "_id": "opendatabase@0.2.0", "_from": "opendatabase@0.2.0", "dist": { "shasum": "36b6c7dd1d4ca3b6d3194b373fe0b687767a7186" }, "_resolved": "https://registry.npmjs.org/opendatabase/-/opendatabase-0.2.0.tgz" }