What is your best guess as to the source of the problem?
I created the seed file with const mongoose = require('mongoose') even though I was using my project 2 as a template. Project 2 was const mongoose = require('./connection') but that's bc we had a connection model.
This is what my entire seed.js model looks like:
///////////////////////////////////////
// Import Dependencies
///////////////////////////////////////
//const mongoose = require('./connection')
const mongoose = require('mongoose')
const Project = require('./project')
///////////////////////////////////////////
// Seed Code
////////////////////////////////////////////
// save the connection in a variable
const db = mongoose.connection;
db.on('open', () => {
// array of starter fruits
const starterProject = {
garmentType: "shirt",
Fabric: "poplin",
Interfacing:"medium-weight fusible",
Notions:["rotary cutter", "shears","point turner"],
pattern: "self-drafted",
}
// when we seed data, there are a few steps involved
// delete all the data that already exists(will only happen if data exists)
Project.remove({})
.then(deletedProjects => {
console.log('this is what remove returns', deletedProjects)
// then we create with our seed data
Project.create(starterProject)
.then((data) => {
console.log('Here is the new seeded data re: starter projects', data)
db.close()
})
.catch(error => {
console.log(error)
db.close()
})
})
.catch(error => {
console.log(error)
db.close()
})
// then we can send if we want to see that data
})
What things have you already tried to solve the problem?
When I tried running db, I get an object with info I'm unsure how to handle. I don't know if there's a clue somewhere in there that I'm missing.
What stack are you using?
(ex: MERN(mongoose + react), DR(django + react), PEN, etc.)
MERN
What's the problem you're trying to solve?
I'm trying to seed data
Post any code you think might be relevant (one fenced block per file)
If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?
when I run npm run seed, this is all I get without any seeding or confirmation of seeding:
If I console log db, I get this along with the code above:
What is your best guess as to the source of the problem?
I created the seed file with
const mongoose = require('mongoose')
even though I was using my project 2 as a template. Project 2 wasconst mongoose = require('./connection')
but that's bc we had a connection model.This is what my entire seed.js model looks like:
What things have you already tried to solve the problem?
When I tried running db, I get an object with info I'm unsure how to handle. I don't know if there's a clue somewhere in there that I'm missing.
Paste a link to your repository here