mongo works
This commit is contained in:
parent
ae6ccd559f
commit
125107da50
937 changed files with 205033 additions and 2 deletions
23
parts/3/followAlong/mongo.js
Normal file
23
parts/3/followAlong/mongo.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
const mongoose = require("mongoose");
|
||||
|
||||
const url = "mongodb://devroot:devroot@localhost:27017/fsopen?authSource=admin";
|
||||
mongoose.set("strictQuery", false);
|
||||
|
||||
mongoose.connect(url);
|
||||
|
||||
const noteSchema = new mongoose.Schema({
|
||||
content: String,
|
||||
important: Boolean,
|
||||
});
|
||||
|
||||
const Note = mongoose.model("Note", noteSchema);
|
||||
|
||||
const note = new Note({
|
||||
content: "HTML is easy",
|
||||
important: true,
|
||||
});
|
||||
|
||||
note.save().then((result) => {
|
||||
console.log("note saved!");
|
||||
mongoose.connection.close();
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue