Version 1.0
This commit is contained in:
commit
a4b0db9118
102 files changed
+16343
No files matched your search
@@ -0,0 +1,23 @@
|
||||
const mongoose = require("mongoose");
|
||||
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const BoardSchema = new Schema({
|
||||
ownerId: { type: Schema.Types.ObjectId, ref: "User", required: true },
|
||||
name: { type: String, required: true, maxLength: 100 },
|
||||
categories: { type: [Object], required: false, default: [] },
|
||||
});
|
||||
|
||||
// Virtual for player's URL
|
||||
BoardSchema.virtual("url").get(function () {
|
||||
// We don't use an arrow function as we'll need the this object
|
||||
return `/board/${this._id}`;
|
||||
});
|
||||
|
||||
BoardSchema.virtual("setFromPostObject").set( function( postObject ){
|
||||
this.name = postObject.boardName;
|
||||
this.categories = postObject.categories;
|
||||
})
|
||||
|
||||
// Export model
|
||||
module.exports = mongoose.model("Board", BoardSchema);
|
||||
Reference in new issue
Block a user