-
Notifications
You must be signed in to change notification settings - Fork 0
/
Comments.js
28 lines (26 loc) · 1.01 KB
/
Comments.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { Mongo } from 'meteor/mongo';
import SimpleSchema from 'simpl-schema';
import { Tracker } from 'meteor/tracker';
/** Encapsulates state and variable values for this collection. */
class CommentsCollection {
constructor() {
// The name of this collection.
this.name = 'CommentsCollection';
// Define the Mongo collection.
this.collection = new Mongo.Collection(this.name);
// Define the structure of each document in the collection.
this.schema = new SimpleSchema({
profileId: String,
visitId: String,
date: Date,
author: String,
comment: String,
}, { tracker: Tracker });
// Attach the schema to the collection, so all attempts to insert a document are checked against schema.
this.collection.attachSchema(this.schema);
// Define names for publications and subscriptions
this.userPublicationName = `${this.name}.publication.user`;
this.adminPublicationName = `${this.name}.publication.admin`;
}
}
export const Comments = new CommentsCollection();