als-seeder
v0.1.0
Published
Simple seeder for inserting data. The package works with mongoose.
Downloads
9
Readme
Als-seeder
About
Simple seeder for inserting data. The package works with mongoose.
Usage
- Create models folder with model File with first capital (like /models/User.js)
- File has to return mongoose model
- Inside models folder create data folder with plural file name (like /models/data/users.js)
- file has to return data inside array for model
- you can use faker if you want
Example
module.exports = [
{
name:process.env.ADMIN_NAME,
email:process.env.ADMIN_EMAIL,
password:process.env.ADMIN_PASSWORD,
verification:'true',
role:0
}
]
- Create cli file as shown below (like /cli.js)
let Seeder = require('als-seeder')
require('dotenv').config()
require('mongoose').connect(process.env.MONGODB,()=>console.log(`MongoDb Connected`))
Seeder.cli(__dirname)
- Use command line:
node cli delete User
- for deleting all data in Usernode cli create User
- for creating new data in User from usersnode cli restore User
- for deleting and then creating new data in User from users