Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Book = require("../model/book");
- // dummy data
- const books = [
- {name: "Name of the Wind", genre: "Fantasy"},
- {name: "The Final Empire", genre: "Fantasy"},
- {name: "The Long Earth", genre: "Sci-Fi"},
- {name: "The Hero of Ages", genre: "Fantasy"},
- {name: "The Colour of Magic", genre: "Fantasy"},
- {name: "The Light Fantastic", genre: "Fantasy"},
- {name: "드래곤볼", genre: "Sci-Fi"}
- ];
- Book.collection.insert(books, function (err, docs) {
- if (err){
- return console.error(err);
- } else {
- console.log("Multiple documents inserted to Collection");
- }
- });
- const mongoose = require('mongoose');
- const Schema = mongoose.Schema;
- const bookSchema = new Schema({
- name: String,
- genre: String
- });
- module.exports = mongoose.model("Book", bookSchema);
Add Comment
Please, Sign In to add comment