Skip to content
This repository was archived by the owner on Oct 21, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions src/dataLayer/model/communityEvent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const mongoose = require('mongoose');

const Schema = mongoose.Schema;

const communityEventSchema = new Schema({
externalId: {
type: 'string',
description: 'Unique ID to refers to events externally',
required: true
},
title: {
type: 'string',
required: true
},
description: {
type: 'string',
required: true
},
owner: {
type: mongoose.Schema.ObjectId,
ref: 'User',
description: 'ID of owner of event',
required: true
},
// Many to many relationship, see
// http://mongoosejs.com/docs/populate.html
attendees: [
{
type: mongoose.Schema.ObjectId,
ref: 'User',
description: 'Attendee'
}
],

date: {
type: 'date',
required: true
},
imageUrl: {
type: 'string'
},
isLocked: {
type: 'boolean',
description: 'Event is locked',
default: true
}
});

module.exports = mongoose.model(
'CommunityEvent',
communityEventSchema,
'communityEvent'
);
15 changes: 14 additions & 1 deletion src/dataLayer/model/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ const mongoose = require('mongoose');
const Schema = mongoose.Schema;

const userSchema = new Schema({
externalId: {
type: 'string',
description: 'A UUID that is communicated externally'
},
accountLinkId: {
type: 'string',
description: 'A uuid used to link SSO and freeCodeCamp accounts together',
Expand Down Expand Up @@ -111,7 +115,16 @@ const userSchema = new Schema({
theme: {
type: 'string',
default: 'default'
}
},
// Many to many relationship, see
// http://mongoosejs.com/docs/populate.html
events: [
{
type: mongoose.Schema.ObjectId,
ref: 'Event',
description: 'Event'
}
]
});

module.exports = mongoose.model('User', userSchema, 'user');
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`createCommunityEvent should throw if an attendee does yet exist 1`] = `"Unable to find attendee: {\\"email\\":\\"yeahnah@example.com\\"}"`;

exports[`createCommunityEvent should throw if an imageUrl is not a valid URL 1`] = `"Expected valid URL string, got \\"notaUrl\\""`;

exports[`createCommunityEvent should throw if an isLocked is not a Boolean 1`] = `"Expected a Boolean value, got \\"notaBoolean\\""`;

exports[`deleteCommunityEvent should return with an error for a non existing event 1`] = `[Error: Event not found]`;
Loading