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;