I am getting an error in MongoDB when trying to seed. The Terminal states that db.collection.remove(... is not a function and I cant figure out what is wrong. I have looked on other stack questions as well as the documentation from MongoDB itself on db.collection.remove(). I do have mongo and mongoose installed via NPM...please see my code below.
'use strict'
// REQUIRE DB
const db = require('./models');
let tacoList = [
{
name: "Beef Taco Boats",
shell: "Hard",
meat: "Beef",
spicy: false,
toppings: "Rice, Beans, Cheese, Avocado, Guac, Pico, Sour Cream, Shredded Lettuce",
recipe: "http://www.delish.com/cooking/recipe-ideas/recipes/a53019/beef-taco-boats-recipe/",
picture: "http://www.delish.com/cooking/recipe-ideas/recipes/a53019/beef-taco-boats-recipe/?zoomable"
}];
db.Taco.remove({}, (err, taco) => {
console.log('Removing Tacos');
db.Taco.create(tacoList, (err,tacos) => {
if(err){
console.log('DB Creation Error: ', err);
}
console.log('Created Tacos');
process.exit();
});
});
via T. Evans
No comments:
Post a Comment