1.2.8 • Published 4 years ago

mass-db-seed v1.2.8

Weekly downloads
7
License
ISC
Repository
github
Last release
4 years ago

mass-db-seed

Helps generate seed data for a SQL database using the faker library.

Installing


npm install mass-db-seed
yarn add mass-db-seed

Example


Note: the attributes variable is a string composed of the faker library's attribute and subattributes.

E.g: if you wanted to use faker.name.firstName as a value, you would include "name.firstName".

const massDbSeed = require("mass-db-seed");

// name of the database table
const tableName = "users";
// number of rows to generate info for
const numRows = 2;
// name of the database fields (columns)
const fields = ["first_name", "last_name", "job_title", "random_number"];
// attribute.subAttribute taken from the faker library
const attributes = ["name.firstName", "name.lastName", "name.jobTitle", "random.number"];

// returns the string and console logs the string
massDbSeed(tableName, numRows, fields, attributes);
//Example output:
INSERT INTO users (first_name, last_name, job_title, random_number) VALUES ('Giovanna', 'Leannon', 'Central Intranet Officer', 76167), ('Brianne', 'Nitzsche', 'Regional Web Executive', 94287)

References


Faker Library

TO DO


  • create CI/CD
  • more examples
  • create table of contents
1.2.8

4 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago