Narcissistic Passion Minified
Wondering what’s next for npm?Check out our public roadmap! »

knex-schema

2.2.1 • Public • Published

knex-schema

Build Status Dependency Status devDependency Status Coverage Status

Knex sync utility.

Install

npm install knex-schema

Usage

var database = require('knex').initialize({ client: 'pg' });
var Manager = require('knex-schema');
var manager = new Manager(database);
var articles = {
  tableName: 'articles',
  build: function (table) {
    table.increments('id').primary();
    table.string('title');
  },
  populate: function (database) {
    return db.knex('articles').insert([
      { title: 'First article' }
    ]);
  }
};
manager.sync([articles]); // Create / Update tables articles.
manager.populate([articles]); // Populate table articles.
manager.reset([articles]); // Remove all data from articles.
manager.drop([articles]); // Drop table articles.

knexSchema(database)

Create a new manager.

var manager = require('knex-schema')(database);

manager.sync(schemas)

Create and update tables specified in schemas.

manager.sync([articles]);

manager.populate(schemas)

Populate tables specified in schemas.

manager.populate([articles]);

manager.reset(schemas)

Remove all rows in tables specified in schemas.

manager.reset([articles]);

manager.drop(schemas)

Drop tables specified in schemas.

manager.drop([articles]);

License

MIT

Keywords

Install

npm i knex-schema

DownloadsWeekly Downloads

665

Version

2.2.1

License

MIT

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar