This commit is contained in:
2018-05-16 18:25:55 +03:00
commit fa053c63d5
9 changed files with 10556 additions and 0 deletions

15
models/Todo.js Normal file
View File

@@ -0,0 +1,15 @@
const mongoose = require('mongoose');
const { Schema } = mongoose;
const todoSchema = Schema({
_id: Schema.Types.ObjectId,
text: {
type: String,
required: true,
},
list: { type: Schema.Types.ObjectId, ref: 'TodoList' },
completed: Boolean,
});
mongoose.model('Todo', todoSchema);

14
models/TodoList.js Normal file
View File

@@ -0,0 +1,14 @@
const mongoose = require('mongoose');
const { Schema } = mongoose;
const todoListSchema = Schema({
_id: Schema.Types.ObjectId,
name: {
type: String,
required: true,
},
todos: [{ type: Schema.Types.ObjectId, ref: 'Todo' }],
});
mongoose.model('TodoList', todoListSchema);