Skip to content

Instantly share code, notes, and snippets.

@cklanac
Last active August 24, 2018 05:34
Show Gist options
  • Save cklanac/ef21459fe456ff7bd16dc28d8bf6028f to your computer and use it in GitHub Desktop.
Save cklanac/ef21459fe456ff7bd16dc28d8bf6028f to your computer and use it in GitHub Desktop.
Sample seed DB
'use strict';
const mongoose = require('mongoose');
const { MONGODB_URI } = require('../config');
const Note = require('../models/note');
const Folder = require('../models/folder');
const Tag = require('../models/tag');
const User = require('../models/user');
const seedNotes = require('../db/seed/notes');
const seedFolders = require('../db/seed/folders');
const seedTags = require('../db/seed/tags');
const seedUsers = require('../db/seed/users');
mongoose.connect(MONGODB_URI)
.then(() => mongoose.connection.db.dropDatabase())
.then(() => {
return Promise.all([
Note.insertMany(seedNotes),
Folder.insertMany(seedFolders),
Folder.ensureIndexes(),
Tag.insertMany(seedTags),
Tag.ensureIndexes(),
User.insertMany(seedUsers),
User.ensureIndexes(),
]);
})
.then(() => mongoose.disconnect())
.catch(err => {
console.error(`ERROR: ${err.message}`);
console.error(err);
});
@IamBeltran
Copy link

How is your file seedusers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment