0.1.7 • Published 8 years ago

lite3 v0.1.7

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

SQLite3 sugar built ontop of node-sqlite3 for Node.js.

NPM

Supported platforms

The sqlite3 module which lite3 is built on works with Node.js v0.10.x, v0.12.x, v4.x, and v5.x.

Binaries for most Node versions and platforms are provided by default via node-pre-gyp.

Purpose

I created this library to simplify querying, updating, inserting a SQLite3 database.

Example of updating a row:

lite3
  .table('users')
  .update('name=?, age=?')
  .where('id=1')
  .values('Sean', '24')

Installing

You can use npm to download and install:

  • The latest lite3 package: npm install lite3

Usage

Check the Apisection to see more examples and uses.

const lite = require('lite3');
const lite3 = new lite('database.db')

lite3
  .table('work_history')
  .selectAll()
  .then(rows => console.log(rows))
  .catch(err => console.log(err));

Api

new lite3(file)

Creates a new Class with the passed in file as a the name of the SQLite3 database that you want to connect.

  • {string} file - filename of the database you want to make SQL operations on.

EX:

const lite = require('lite3');
const lite3 = new lite('DBname.db');

lite3.table(tbl)

Sets the lite3.tableName property and returns the class to perform chainable SQL queries on the specified table.

  • {string} tbl - Name of the table desired to perform SQL queries.

EX:

lite3
  .table('blog_post')

Once the table is set, you can perform multiple queries on the table. To perform queries on another table you must specifiy the table by running lite.table(tbl) again to set a new table to perform queries.

Example of running two seperate queries on the same table blog_post:

lite3
  .table('blog_post')
  .selectAll()
  .then(rows => console.log(rows))
  .catch(err => console.log(err));
  
lite3
  .update('date=?, title=?')
  .where('id=?')
  .values(['04-12-2016',' Awesome New Tittle', 1], true)
  .then(changes =>  console.log(changes))
  .catch(err => console.log(err));
0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.1

8 years ago

0.0.0

8 years ago