Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

simple-knex-fixtures

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-knex-fixtures

knex fixture loader

latest
Source
npmnpm
Version
2.0.3
Version published
Weekly downloads
201
-14.47%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status codecov

simple-knex-fixtures

A simple library to help you load data to a database to facilitate testing.

Caveats:

  • does not protect against duplicate records

Install

npm install --save simple-knex-fixtures

Test

npm test

Usage

const connection = require("knex")({
  client: "mysql",
  connection: {
    host : "127.0.0.1",
    user : "your_database_user",
    password : "your_database_password",
    database : "myapp_test"
  }
});

const fixtures = require("simple-knex-fixtures");

await fixtures.loadFile("fixtures/file.json", connection)

await fixtures.loadFiles("fixtures/*.json", connection)

await fixtures.loadFiles([
    "fixtures/file1.json",
    "fixtures/file2.json",
], connection);

File formats

javascript

module.exports = [
  {
    "table": "users",
    "data": {
      "id": 1,
      "first": "john",
      "last": "doe"
    }
  }
];

json

[
  {
    "table": "users",
    "data": {
      "id": 1,
      "first": "john",
      "last": "doe"
    }
  }
]

yaml

fixtures:
  -
    table: users
    data:
      id: 1
      first: john
      last: doe

Keywords

knex

FAQs

Package last updated on 14 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts