Skip to content

Commit

Permalink
Added group chat model
Browse files Browse the repository at this point in the history
  • Loading branch information
ranilwallace committed Jun 26, 2020
1 parent 0d974a9 commit a7959fd
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
28 changes: 28 additions & 0 deletions models/Group.js
Original file line number Diff line number Diff line change
@@ -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);
5 changes: 5 additions & 0 deletions models/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
1 change: 0 additions & 1 deletion schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ const typeDefs = gql`
imageUrl: String
videoUrl:String
creator: User
organization: Organization
}

input PostInput {
Expand Down

0 comments on commit a7959fd

Please sign in to comment.