mongoose-seeder-lib
v1.0.2
Published
mongoose seeder library
Downloads
1
Readme
#mongoose-seeder-lib
Seed data into mongoose schemas
####Install
npm i --save mongoose-seeder-lib
####Use
- import
const { createSeeder, dropDatabase } = require('mongoose-seeder-lib');
- create custom data to seed
const data = [
{
title: "Jordan 1 Retro High 85 Varsity Red",
price: 679,
currency: "USD",
stock: 30,
},
{
title: "Jordan 1 Retro High Yellow Ochre",
price: 357,
currency: "USD",
stock: 15,
},
{
title: "Jordan 1 Retro High Black Gym Red",
price: 90,
currency: "USD",
stock: 107,
},
];
####Use createSeeder
/**
* Seed passed data
* @return { Promise }
*/
const res = await createSeeder(data, schema);
####Use dropDatabase
/**
* Remove all data from table
* @return { Promise }
*/
const res = await dropDatabase(schema);