fast and simple dao using knex
// const = { connect, CrudOperations } = require('@day1co/fastdao');
import { connect, CrudOperations } from '@day1co/fastdao';
const knex = connect({ ... });
// to use a separated connection for select
const knexReplica = connect({ ... });
const postCrud = CrudOperations.create({ knex, knexReplica, table: 'post' });
await postCrud.select({ ... });
await postCrud.selectFirst({ ... });
await postCrud.selectById(1);
await postCrud.count({ ... });
await postCrud.exist({ ... });
await postCrud.insert({ ... });
await postCrud.update({ ... });
await postCrud.updateById(id, { ... });
await postCrud.delete({ ... });
await postCrud.deleteById(id);
await knex.transaction(async (tx) => {
await postCrud.transacting(tx).insert(...);
await postCrud.transacting(tx).updateById(...);
await postCrud.transacting(tx).deleteById(...);
});
$ npm test
$ npm run build
$ npm start
may the SOURCE be with you...