diff options
Diffstat (limited to 'models')
-rw-r--r-- | models/account.js | 30 | ||||
-rw-r--r-- | models/cmmnt.js | 15 | ||||
-rw-r--r-- | models/picture.js | 9 | ||||
-rw-r--r-- | models/recipe.js | 30 | ||||
-rw-r--r-- | models/step.js | 9 | ||||
-rw-r--r-- | models/user.js | 11 |
6 files changed, 104 insertions, 0 deletions
diff --git a/models/account.js b/models/account.js new file mode 100644 index 0000000..2c73763 --- /dev/null +++ b/models/account.js @@ -0,0 +1,30 @@ +const mongoose = require("mongoose"); + +const AccountSchema = new mongoose.Schema({ + bio: { + name: String, + about: String, + website: String + }, + author: { + id: { + type: mongoose.Schema.Types.ObjectId, + ref: "User", + }, + username: String, + }, + recipes: [ + { + type: mongoose.Schema.Types.ObjectId, + ref: "Recipe", + }, + ], + favorites: [ + { + type: mongoose.Schema.Types.ObjectId, + ref: "Recipe", + }, + ] +}); + +module.exports = new mongoose.model("Account", AccountSchema); diff --git a/models/cmmnt.js b/models/cmmnt.js new file mode 100644 index 0000000..4373e8a --- /dev/null +++ b/models/cmmnt.js @@ -0,0 +1,15 @@ +const mongoose = require('mongoose'); + +//Schema Setup +const cmmntSchema = new mongoose.Schema({ + text: String, + author: { + id: { + type: mongoose.Schema.Types.ObjectId, + ref: 'User' + }, + username: String + } +}); + +module.exports = new mongoose.model('Cmmnt', cmmntSchema); diff --git a/models/picture.js b/models/picture.js new file mode 100644 index 0000000..d80810c --- /dev/null +++ b/models/picture.js @@ -0,0 +1,9 @@ +const mongoose = require('mongoose'); + +//Schema Setup +const pictureSchema = new mongoose.Schema({ + type: String, + data: Buffer +}); + +module.exports = new mongoose.model('Picture', pictureSchema); diff --git a/models/recipe.js b/models/recipe.js new file mode 100644 index 0000000..e866f5f --- /dev/null +++ b/models/recipe.js @@ -0,0 +1,30 @@ +const mongoose = require('mongoose'); + +const recipeSchema = new mongoose.Schema({ + title: String, + picture: String, + category: String, + ingridients: [String, String], + isLiked: Number, + steps: [ + { + type: mongoose.Schema.Types.ObjectId, + ref: 'Step' + } + ], + author: { + id: { + type: mongoose.Schema.Types.ObjectId, + ref: 'User' + }, + username: String + }, + comments: [ + { + type: mongoose.Schema.Types.ObjectId, + ref: 'Cmmnt' + } + ] +}); + +module.exports = new mongoose.model('Recipe', recipeSchema); diff --git a/models/step.js b/models/step.js new file mode 100644 index 0000000..28fcc98 --- /dev/null +++ b/models/step.js @@ -0,0 +1,9 @@ +const mongoose = require('mongoose'); + +const stepSchema = new mongoose.Schema({ + number: Number, + photo: String, + step: String +}); + +module.exports = new mongoose.model('Step', stepSchema);
\ No newline at end of file diff --git a/models/user.js b/models/user.js new file mode 100644 index 0000000..a38cf67 --- /dev/null +++ b/models/user.js @@ -0,0 +1,11 @@ +const mongoose = require("mongoose"), + passportLocalMongoose = require("passport-local-mongoose"); + +const UserSchema = new mongoose.Schema({ + username: String, + password: String, +}); + +UserSchema.plugin(passportLocalMongoose); + +module.exports = mongoose.model("User", UserSchema); |