# lite3

> A abstraction layer built on top of node sqlite3 that allows for easier SQL queries and promises.

Latest version **0.1.7** (published 2016-04-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install lite3
pnpm add lite3
yarn add lite3
bun add lite3
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.7 |
| Published | 2016-04-13 |
| First published | 2016-04-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Sean Parsons |
| Maintainers | seanpar203 |
| Keywords | sqlite3, sugar, promises |

## Links

- npm: https://www.npmjs.com/package/lite3
- Repository: https://github.com/seanpar203/lite3
- Homepage: https://github.com/seanpar203/lite3#readme
- Issues: https://github.com/seanpar203/lite3/issues
- npm.io page: https://npm.io/package/lite3

## Dependencies (2)

- [sqlite3](https://npm.io/package/sqlite3.md) ^3.1.3
- [bluebird](https://npm.io/package/bluebird.md) ^3.3.4

## Alternatives

- [promise-throttle](https://npm.io/package/promise-throttle.md) — 44.2K weekly downloads
- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads

## Recent versions

- 0.1.7 (latest) — 2016-04-13
- 0.1.6 — 2016-04-13
- 0.1.5 — 2016-04-13
- 0.1.4 — 2016-04-13
- 0.1.3 — 2016-04-13
- 0.1.2 — 2016-04-12
- 0.1.1 — 2016-04-12
- 0.1.0 — 2016-04-11

## README

SQLite3 sugar built ontop of [node-sqlite3](https://github.com/mapbox/node-sqlite3) for [Node.js](https://nodejs.org/).

[![NPM](https://nodei.co/npm/lite3.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/lite3/)

## 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](https://github.com/mapbox/node-pre-gyp).


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

Example of updating a row:
``` js
lite3
  .table('users')
  .update('name=?, age=?')
  .where('id=1')
  .values('Sean', '24')
```

# Installing
You can use [`npm`](https://www.npmjs.com/) to download and install:

* The latest `lite3` package: `npm install lite3`

# Usage
Check the [`Api`](#api)section to see more examples and uses. 
``` js
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: 

``` js
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: 

``` js 

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`: 

```js

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));
```

---
_Source: https://npm.io/package/lite3 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
