Skip to content
This repository was archived by the owner on Oct 21, 2020. It is now read-only.

Commit eda06a1

Browse files
committed
feat: add community events
1 parent bbe55f8 commit eda06a1

20 files changed

+1268
-6
lines changed

src/dataLayer/model/communityEvent.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const mongoose = require('mongoose');
2+
3+
const Schema = mongoose.Schema;
4+
5+
const communityEventSchema = new Schema({
6+
externalId: {
7+
type: 'string',
8+
description: 'Unique ID to refers to events externally',
9+
required: true
10+
},
11+
title: {
12+
type: 'string',
13+
required: true
14+
},
15+
description: {
16+
type: 'string',
17+
required: true
18+
},
19+
owner: {
20+
type: mongoose.Schema.ObjectId,
21+
ref: 'User',
22+
description: 'ID of owner of event',
23+
required: true
24+
},
25+
// Many to many relationship, see
26+
// http://mongoosejs.com/docs/populate.html
27+
attendees: [
28+
{
29+
type: mongoose.Schema.ObjectId,
30+
ref: 'User',
31+
description: 'Attendee'
32+
}
33+
],
34+
35+
date: {
36+
type: 'date',
37+
required: true
38+
},
39+
imageUrl: {
40+
type: 'string'
41+
},
42+
isLocked: {
43+
type: 'boolean',
44+
description: 'Event is locked',
45+
default: true
46+
}
47+
});
48+
49+
module.exports = mongoose.model(
50+
'CommunityEvent',
51+
communityEventSchema,
52+
'communityEvent'
53+
);

src/dataLayer/model/user.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ const mongoose = require('mongoose');
33
const Schema = mongoose.Schema;
44

55
const userSchema = new Schema({
6+
externalId: {
7+
type: 'string',
8+
description: 'A UUID that is communicated externally'
9+
},
610
accountLinkId: {
711
type: 'string',
812
description: 'A uuid used to link SSO and freeCodeCamp accounts together',
@@ -111,7 +115,16 @@ const userSchema = new Schema({
111115
theme: {
112116
type: 'string',
113117
default: 'default'
114-
}
118+
},
119+
// Many to many relationship, see
120+
// http://mongoosejs.com/docs/populate.html
121+
events: [
122+
{
123+
type: mongoose.Schema.ObjectId,
124+
ref: 'Event',
125+
description: 'Event'
126+
}
127+
]
115128
});
116129

117130
module.exports = mongoose.model('User', userSchema, 'user');
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`createCommunityEvent should throw if an attendee does yet exist 1`] = `"Unable to find attendee: {\\"email\\":\\"[email protected]\\"}"`;
4+
5+
exports[`createCommunityEvent should throw if an imageUrl is not a valid URL 1`] = `"Expected valid URL string, got \\"notaUrl\\""`;
6+
7+
exports[`createCommunityEvent should throw if an isLocked is not a Boolean 1`] = `"Expected a Boolean value, got \\"notaBoolean\\""`;
8+
9+
exports[`deleteCommunityEvent should return with an error for a non existing event 1`] = `[Error: Event not found]`;

0 commit comments

Comments
 (0)