This is a port to Expo for react-native. Require expo-sqlite
to be installed and configured first.
SQLite Expo Docs
Because there are limited tools for the Expo platform,
we only support "sqlite" driver.
A SQL query builder that is flexible, portable, and fun to use!
A batteries-included, multi-dialect (MSSQL, MySQL, PostgreSQL, SQLite3, Oracle(including Oracle Wallet Authentication), WebSQL) query builder for
Node.js and the Browser, featuring:
Read the full documentation to get started!
For support and questions, join the #bookshelf
channel on freenode IRC
For an Object Relational Mapper, see:
To see the SQL that Knex will generate for a given query, see: Knex Query Lab
Examples
We have several examples on the website. Here is the first one to get you started:
var knex = require('knex')({
dialect: 'sqlite3'
});
knex.schema
.createTable('users', function(table) {
table.increments('id');
table.string('user_name');
})
.createTable('accounts', function(table) {
table.increments('id');
table.string('account_name');
table
.integer('user_id')
.unsigned()
.references('users.id');
})
.then(function() {
return knex.insert({ user_name: 'Tim' }).into('users');
})
.then(function(rows) {
return knex.table('accounts').insert({ account_name: 'knex', user_id: rows[0] });
})
.then(function() {
return knex('users')
.join('accounts', 'users.id', 'accounts.user_id')
.select('users.user_name as user', 'accounts.account_name as account');
})
.map(function(row) {
console.log(row);
})
.catch(function(e) {
console.error(e);
});