homepage
knex-pg-builderA small utility to automate the table creation for knex.
Why?
I don't want to use ORMs like bookshelf, but I still miss the one-command database build process.
Installation
npm i -D knex-pg-builder
Basic Usage
const createSchemas clearSchemas = ; db
check __tests__/test.ts
for a complete example.
Docs
Tips
- why use Map instead of object?
When a table A has a reference to another table B, table A must be created after
tableB, but object.keys
doesn't ensure the order, eg.
object // may be ['a', 'b'] or ['b', 'a']
but Map will keep the same order when items are set, eg.
var m = mm Array // generate [['a', 1], ['b', 1]]