knex-cordova-sqlite

1.0.5 • Public • Published

knex-cordova-sqlite

Allows you to use Knex inside a Cordova app.

Prerequisites

This library does not actually provide any bindings to sqlite, but instead connects the cordova-sqlite-storage provided API to Knex.

Therefore, you need to add the cordova-sqlite-storage plugin to your app.

Installation

npm install --save knex-cordova-sqlite

Example Usage

const knex = require('knex')({
  client: require('knex-cordova-sqlite'),
  connection: {
    filename: 'todos-' + Date.now() + '.db'
  }
});

async function init () {
  await knex.schema.createTable('todos', table => {
    table.increments('id');
    table.string('title');
  })
}

function addTodo (todo) {
  return knex('todos').insert(todo)
}

function getTodos () {
  return knex('todos').select('*')
}

module.exports = {
  init,
  addTodo,
  getTodos
}

Package Sidebar

Install

npm i knex-cordova-sqlite

Weekly Downloads

0

Version

1.0.5

License

MIT

Unpacked Size

3.55 kB

Total Files

4

Last publish

Collaborators

  • markwylde