@rappopo/dab-knex
v0.6.9
Published
A KnexJS data access layer for @rappopo/dab
Downloads
45
Maintainers
Readme
@rappopo/dab-knex
A Rappopo DAB implementation for Knex
Installation
Simply invoke this command in your project folder:
$ npm install --save @rappopo/dab-knex
Don't forget to also install the needed client library, e.g (if you choose to use sqlite3):
$ npm install sqlite3
And within your script:
const DabKnex = require('@rappopo/dab-knex')
const dab = new DabKnex({
client: 'sqlite3',
connection: {
filename: '/tmp/mydb.sqlite3'
}
})
// prepare collections
dab.createCollection({ name: 'test' })
.then(result => {
return dab.bulkCreate(data, { collection: 'test' })
})
...
// lets dab!
dab.findOne('my-doc', 'test').then(function(doc) { ... })
Options
client
: your Knex's client database library
connection
: your Knex's connection settings
Features
- [x] find
- [x] findOne
- [x] create
- [x] update
- [x] remove
- [x] bulkCreate
- [x] bulkUpdate
- [x] bulkRemove
- [x] copyFrom
- [x] copyTo
- [x] createCollection
- [x] renameCollection
- [x] removeCollection