Skip to content

Commit

Permalink
add task model
Browse files Browse the repository at this point in the history
  • Loading branch information
Djibba committed Mar 3, 2023
1 parent 25b3bae commit d2578d7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
9 changes: 8 additions & 1 deletion controllers/taskController.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
const mongoose = require('mongoose');
const Task = require('../models/taskModel')

const getAllTasks = (req, res, next) => {
res.send('all tasks');
};

const createTasks = (req, res, next) => {
const createTasks = async (req, res, next) => {

try {

} catch (error) {

}

};

Expand Down
2 changes: 1 addition & 1 deletion db/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ require('dotenv').config();
const mongoose = require('mongoose');
const connectionString = "mongodb+srv://" + process.env.DB_USER + ":" + process.env.DB_PASSWORD + "@"+ process.env.DB_HOST +"/" + process.env.DB + "?retryWrites=true&w=majority";

mongoose.connect(connectionString, { useNewUrlParser: true, useUnifiedTopology: true })
mongoose.connect(connectionString, { useNewUrlParser: true, useUnifiedTopology: true, })
.then(() => console.log('Connection for database successfully !'))
.catch((err) => console.log(err));
13 changes: 13 additions & 0 deletions models/taskModel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const mongoose = require('mongoose');

const taskSchema = mongoose.Schema({
name: {
type: String,
required: true
},
completed: {
type: Boolean,
}
})

module.exports = mongoose.model('task', taskSchema)

0 comments on commit d2578d7

Please sign in to comment.