Please enable JavaScript.
Coggle requires JavaScript to display documents.
task resource - Coggle Diagram
task resource
1
identify the schema
title
String
required
description
String
completed
Boolean
default: false
dueDate
Date
createdAt
Date
default: Date.now()
2
Create amodel
mongoose.model("modelName", schema)
Creator a constructor function
3
setup API routes
list
GET '/api/tasks
Task.find()
return all the tasks
create
POST '/api/tasks
Create task obj
task.save()
return the created task
show
GET '/api/tasks/:id
Task.findById(id)
return task
update
PUT '/api/tasks/:id
Task.findByIdAndUpdate()
return the updated task
destroy
DELETE '/api/tasks/:id
Task.findByIdAndDelete(id)
return the deleted task