feku
v0.1.1
Published
Generate intelligent fake data
Downloads
37
Readme
Feku
Generate intelligent random data based on a spec file.
Features
- CLI
- examples
- helper functions to generate random data
- customizable output JSON lines (jsonld / ndjson) or JSON Array
- custom spec files to generate new rows based on previously generated data (for example account balance must take into account previous transaction as well)
Usage
Options
--count
or-n
accepts number of items to generate--array
or-a
Examples:
feku examples/movies.js
by default produces json lines (jsonld / ndjson)
{"title":"sint voluptatem","year":2014,"rating":4,"duration":102,"genre":"Romance","image":"http://loremflickr.com/640/480/abstract","description":"Laudantium minima quae libero asperiores voluptatem adipisci. Doloribus rerum praesentium.","cast":["Shawna Pollich DVM","Miss Josefina Schmidt","Lizeth"]}
{"title":"aperiam nostrum odit excepturi sint","year":2001,"rating":2,"duration":110,"genre":"Comedy","image":"http://loremflickr.com/640/480/business","description":"Fuga quod culpa qui. Provident voluptatum qui eum omnis.","cast":["Phil Casper","Sergio Pfeffer","Yvonne"]}
{"title":"iure","year":1985,"rating":5,"duration":134,"genre":"Drama","image":"http://loremflickr.com/640/480/abstract","description":"Quia incidunt ipsum maiores. Libero similique assumenda deserunt aliquam harum iure nemo fuga consequatur.","cast":["Kristin Hintz","Dr. Danielle Batz","Mavis"]}
{"title":"aliquam","year":1989,"rating":1,"duration":113,"genre":"Comedy","image":"http://loremflickr.com/640/480/people","description":"Et omnis ipsam placeat est harum adipisci. Illum et consequatur.","cast":["Gerardo MacGyver","Miss Lester Brakus","Retha"]}
feku examples/people.js --count=5 --array
produces an array of five person objects
[
{
"name": "Lindsay Swaniawski",
"age": 85
},
{
"name": "Mattie Romaguera",
"age": 37
},
{
"name": "Tabitha Harber",
"age": 99
},
{
"name": "Virginia Schinner",
"age": 69
},
{
"name": "Kara Kihn",
"age": 47
}
]
We can pass in extra args like start and end date.
feku examples/account.js --count 5 --startDate 2022-04-01 --endDate 2022-04-30
{"date":"2022-04-01","desc":"laudantium quae","amt":-8,"bal":1241}
{"date":"2022-04-02","desc":"dolorum eligendi omnis officiis qui","amt":22,"bal":1263}
{"date":"2022-04-05","desc":"rem qui incidunt et","amt":-61,"bal":1202}
{"date":"2022-04-08","desc":"libero porro","amt":-32,"bal":1170}
{"date":"2022-04-20","desc":"aut id","amt":-20,"bal":1150}
Writing a spec file
At minimum, the spec file needs to export a default function (you can give it whatever name the suits it purpose, see examples)
export default function rowBuilder({faker}) {
return {
name: faker.name.findName()
}
}
we can export initialContext
, that is passed to the rowBuilder as well which can be used to control seed data.
These attributes can be overridden from the CLI as well.
export const initialContext = {
count: 30
}