db3-config

1.3.0 • Public • Published

Db3 config is a tool for syncing SQL database structure with JSON config.

Why do I need it?

To store your database structure as JSON and sync it with real database.

Init

var db = require('db3').connect()
var db3Config = require('db3-config')(db)

.pull(done)

Reads data from db into JSON.

db3Config.pull(function (err, data) {
  console.log(data) //outputs JSON config
})

.diff(config, done)

Calculates diff

db3Config.diff(config, function (err, data) {
  //data is diff
})

.push(diff, done)

Apply diff to the db

db3Config.push(diff, function (err) {})

Config format

{
  "table": {
    "user": {
      "field": {
        "id": true, //will be bigint primary key, auto_increment
        "username": "text",
        "password": "varchar(32)",
        "subscribed": {
          "dataType": "tinyint",
          "default": 0
        }
      },
      "key": {
        "subscribed": true
      }
    }
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i db3-config

Weekly Downloads

28

Version

1.3.0

License

MIT

Last publish

Collaborators

  • afanasy