Skip to content

realglobe-Inc/pon-task-db

Repository files navigation

pon-task-db

Build Status npm Version JS Standard

DB task set for pon

Installation

$ npm install pon-task-db --save

Usage

'use strict'

const pon = require('pon')
const {setup, seed, dump, migrate} = require('pon-task-db')

async function tryExample () {
  const createDB = () => {/*...*/}

  const run = pon({
    'db:setup': setup(createDB),
    'db:seed': seed(createDB, 'db/seeds/:env/*.seed.json')
  })

  run('db:seed')
}

tryExample()

Signatures

define(options) -> function

Define task

Param type Description
options Object Optional settings

drop(db, options) -> function

Define task to drop database

Param type Description
db function|ClayLump DB instance or it's creator
options Object Optional settings
options.unless string NODE_ENV to skip

dump(db, dirname, options) -> function

Define task to dump database

Param type Description
db function|ClayLump DB instance or it's creator
dirname string Dirname to save dump
options Object Optional settings
options.max number Rotation max count

exec(db, options) -> function

Define task to exec database

Param type Description
db function|ClayLump DB instance or it's creator
options Object Optional settings

migrate(db, handlers) -> function

Define task

Param type Description
db function|ClayLump DB instance or it's creator
handlers Object Migration handlers

refresh(db, options) -> function

Define task to refresh database

Param type Description
db function|ClayLump DB instance or it's creator
options Object Optional settings

setup(db, options) -> function

Define task to setup database

Param type Description
db function|ClayLump DB instance or it's creator
options Object Optional settings

License

This software is released under the Apache-2.0 License.

Links