diff --git a/models/Group.js b/models/Group.js new file mode 100644 index 0000000000..df1c43990b --- /dev/null +++ b/models/Group.js @@ -0,0 +1,28 @@ +const mongoose = require("mongoose"); + +const Schema = mongoose.Schema; + +const groupSchema = new Schema({ + title: { + type: String, + required: true, + }, + description: { + type: String, + }, + createdAt: { type: Date, default: Date.now }, + organization: { + type: Schema.Types.ObjectId, + ref: "Organization", + required: true, + }, + admins: [ + { + type: Schema.Types.ObjectId, + ref: "User", + required: true, + }, + ], +}); + +module.exports = mongoose.model("Group", groupSchema); diff --git a/models/Message.js b/models/Message.js index 8989600435..e57e2159df 100644 --- a/models/Message.js +++ b/models/Message.js @@ -26,6 +26,11 @@ const messageSchema = new Schema({ ref: "Organization", required:true }, + group: { + type: Schema.Types.ObjectId, + ref: "Group", + required:true + }, }) module.exports = mongoose.model("Message", messageSchema); diff --git a/schema.graphql b/schema.graphql index 428b45f32a..7c57535c06 100644 --- a/schema.graphql +++ b/schema.graphql @@ -155,7 +155,6 @@ const typeDefs = gql` imageUrl: String videoUrl:String creator: User - organization: Organization } input PostInput {