1.0.2 • Published 8 years ago

dbify v1.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

dbify

Browserify transform to inline the results of SQL queries

Example

var dbify = require('dbify');
var data = dbify('select * from "table"');

becomes

var data = [{"id":1,"value":"first val"},{"id":2,"value":"second val"},{"id":3,"value":"third val"}];

Installation

$ npm install dbify

# Then add one of the following depending on which DB you plan to use:
$ npm install pg
$ npm install sqlite3
$ npm install mysql
$ npm install mysql2
$ npm install mariasql
$ npm install strong-oracle
$ npm install oracle
$ npm install mssql

and use it with browserify like

$ browserify -t dbify input.js -o output.js

see https://github.com/substack/browserify-handbook#transforms for more info on browserify transforms.

Configuration

Under the hood this project relies on knex. To see full configuration documentation see http://knexjs.org/. In your package.json file add a dbify field:

sqlite example:

{
  "..."
  "dbify": {
    "client": "sqlite",
    "connection": {
      "filename": "database.sqlite"
    }
  }
}

mysql example:

{
  "..."
  "dbify": {
    "client": "mysql",
    "connection": {
      "host" : "127.0.0.1",
      "user" : "your_database_user",
      "password" : "your_database_password",
      "database" : "myapp_test"
    }
  }
}

License

MIT