2025-06-01 23:23:55 +02:00
|
|
|
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,
|
|
|
|
|
});
|
|
|
|
|
|
2025-06-01 23:33:27 +02:00
|
|
|
/* note.save().then((result) => {
|
2025-06-01 23:23:55 +02:00
|
|
|
console.log("note saved!");
|
|
|
|
|
mongoose.connection.close();
|
2025-06-01 23:33:27 +02:00
|
|
|
});
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
Note.find({}).then((result) => {
|
|
|
|
|
result.forEach((note) => {
|
|
|
|
|
console.log(note);
|
|
|
|
|
});
|
|
|
|
|
mongoose.connection.close();
|
2025-06-01 23:23:55 +02:00
|
|
|
});
|