-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mikhail.Angelov
committed
Nov 30, 2019
1 parent
1163567
commit 06d131f
Showing
8 changed files
with
327 additions
and
382 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
const mongoose = require('mongoose') | ||
const mongoUrl = process.env.MONGO_URL || 'mongodb://localhost:27017/example' | ||
mongoose.connect(mongoUrl) | ||
const TaskSchema = new mongoose.Schema({ | ||
|
||
let client | ||
mongoose.connect(mongoUrl).then(c => { | ||
client = c | ||
}) | ||
const Task = mongoose.model('tasks', { | ||
name: String, | ||
started: Date, | ||
completed: Boolean, | ||
}) | ||
const Task = mongoose.model('tasks', TaskSchema) | ||
|
||
module.exports = { | ||
getTasks: () => Task.find(), | ||
addTask: data => new Task(data).save(), | ||
deleteTask: taskId => Task.findByIdAndRemove(taskId) | ||
deleteTask: taskId => Task.findOneAndDelete({ _id: taskId }), | ||
getClient: () => client, | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.