fakerdb
Generate an unlimited stream of JSON schema instances using json-schema-faker, faker, chance and insert the data into a supported database, e.g.: nedb, mongodb, postgres, mssql.
Getting Started
npm install # run docker containerdocker-compose up -d npm test # stop docker containerdocker-compose down
Test Results and Performance
Test Environment
- Intel® Core™ i7-3520M CPU @ 2.90GHz × 4
- 7.5 GiB
- Linux 64 bit
JSON schema
// person.json
Insert 10^5 Records
Insert 10^6 Records
Insert 10^7 Records
API Usage
Install
npm i fakerdb
Stream to STDOUT
// examples/faker-stdout.js var replay jsf = faker = jsonSchemaFaker = path = ; jsonSchemaFaker; const SCHEMA_OBJ = type: 'object' properties: name: type: 'string' faker: 'name.findName' required: 'name' ; ; const SCHEMA_FILE = path; ;
Stream to file with nedb
// examples/faker-nedb.js let generate = Datasource = db = filename: 'faker.db' autoload: true path = ; const REPLAY = 1000;const SCHEMA = path;const OPTS = replay: REPLAY insert: blockSize: 1000 ; ;
Stream to database
fakerdb CLI
Use
npm i -g fakerdbfakerdb --help
Custom Faker Example
Create Standard Normal Distributed Samples
Use
cd examples/faker
fakerdb g -r 200000 -i person.json -f custom-jsf.js -b 1000 -o people.db