1.0.11 • Published 3 years ago

knex-dump v1.0.11

Weekly downloads
67
License
GPL-3.0
Repository
github
Last release
3 years ago

Wigy's Knex Dump

This is a tool to backup and restore small Knex-based databases. Note that this is using only in-memory JSON-blocks and does not use streaming. Thus it is not suitable for huge databases.

Usage

Command line

In the directory containing a knexfile.js, you can save all data to the dump file:

    knex-dump --file dump.json dump

Then it can be restored to the database

    knex-dump --file dump.json restore

For seed data

In a project using Knex, you can make seed data managament easy. Add a script

  "scripts": {
    ...
    "save": "knex-dump --file seeds/data.json restore"
  },

to your package.json. Then you can dump the current state of the database as seed data by running

    npm run save

Then you need only one seed file, for example seeds/load-database.js, having

exports.seed = function(knex, Promise) {
  return require('knex-dump').load(__dirname + '/../knexfile.js', __dirname + '/data.json');
};

Version history

  • 1.0.0 Simple dumping and restoring on a file.
  • 1.0.1 Canonical sorting for all columns.
  • 1.0.2 An interface for using neat-dump as a Node-module.
  • 1.0.3 Avoid crash if data is missing.
  • 1.0.4 Load data in chunks to avoid sqlite limitations.
  • 1.0.5 MSSQL support.
  • 1.0.6 Postgres support.
1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

4 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

6 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.0

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago