Skip to content

jojomak13/mongo-data-factory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mongo-data-factory

Initialize Factory Seeder

first you need to define your collecetion (table) schema for this example i have a table called Country

const countryFactory = Factory.define(Country, (faker: Faker.FakerStatic) => {
  return {
    name: faker.address.country(),
    code: faker.address.countryCode(),
    currency: faker.finance.currencyCode(),
    timezone: faker.address.timeZone(),
  };
});

Run your factory 🚀

After initialize it you just run one line of code

you could pass as argument your number of records you want to create by default it creates only only one record

countryFactory.create(); // will create one reacord

countryFactory.create(10); // will create 10 reacords

countryFactory.create().then(() => {
  // you could run some logic here to 😀
});