This repository has been archived on 2022-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
brainlet/models/Channel.js

19 lines
489 B
JavaScript
Raw Permalink Normal View History

const mongoose = require("mongoose");
const User = require("./User");
const channelSchema = new mongoose.Schema({
title: String,
creator: {type: mongoose.Schema.Types.ObjectId, ref: "User"}
});
channelSchema.method("getPublicObject", function() {
return {
title: this.title,
creator: this.populate("creator", User.getPulicFields()).creator,
_id: this._id
};
});
const Channel = mongoose.model("Channel", channelSchema);
module.exports = Channel;