mirror of
https://github.com/usatiuk/ustk-todolist.git
synced 2025-10-28 23:57:49 +01:00
init
This commit is contained in:
15
models/Todo.js
Normal file
15
models/Todo.js
Normal 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
14
models/TodoList.js
Normal 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);
|
||||
Reference in New Issue
Block a user