-
Notifications
You must be signed in to change notification settings - Fork 1
/
seed.js
23 lines (21 loc) · 538 Bytes
/
seed.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require('dotenv-safe').config()
const { Seeder } = require('mongo-seeding')
const path = require('path')
const config = {
database: process.env.MONGO_URI,
inputPath: path.resolve(__dirname, './data'),
dropDatabase: false
}
const seeder = new Seeder(config)
const collections = seeder.readCollectionsFromPath(path.resolve('./data'))
const main = async () => {
try {
await seeder.import(collections)
console.log('Seed complete!')
process.exit(0)
} catch (err) {
console.log(err)
process.exit(0)
}
}
main()