This work is produced by Mats Loock for the course Server-based Web Programming (1DV023) at Linnaeus University.
All content in this work excluding photographs, icons, picture of course literature and Linnaeus University
logotype and symbol, is licensed under a
Creative Commons Attribution 4.0
International License.
If you change the content do not use the photographs, icons, picture of the course literature or Linnaeus University logotype and symbol in your new work!
At all times you must give credit to: ”Linnaeus university – Server-based Web Programming (1DV023)” with the link https://coursepress.lnu.se/kurs/serverbaserad-webbprogrammering/ and to the Creative Common-license above.
npm install mongoose
mongoose.connect()
method.
mongodb+srv://<dbuser>:<password>@<cluster>.mongodb.net/<name>?retryWrites=true&w=majority
Promise
.connected
).error
).disconnected
).mongoose.model(modelName, schema)
.Task.js
) resides in the models
directory.:id
above, are named URL segments that are used to capture the values specified at their position.req.params
object, with the name of the route parameter specified in the path as their respective keys.find
, and pass an empty object, to find all documents in a collection.updateOne
to update a document in the database.deleteOne
to remove the document that matches the condition.MemoryStorage
.
flash
to the response object.flash
session variable.