Skip to content

Commit

Permalink
Merge 2520d4b into 3af4685
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancisZamora committed Jul 9, 2018
2 parents 3af4685 + 2520d4b commit 2c57de8
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 2 deletions.
58 changes: 58 additions & 0 deletions server/models/analytic.js
@@ -0,0 +1,58 @@
'use strict';
const Joi = require('joi');
const Assert = require('assert');
const AnchorModel = require('../anchor/anchor-model');

class Analytic extends AnchorModel {

static async create(event,name,data,userId) {


Assert.ok(event, 'Missing event argument');
Assert.ok(name, 'Missing name argument');
Assert.ok(data, 'Missing data arugment');
Assert.ok(userId, 'Missing userId argument');

const document = new this({
event,
name,
data,
userId,
createdAt: new Date()

});

const analytics = await this.insertOne(document);

return analytics[0];

}
}

Analytic.collectionName = 'analytics';

Analytic.schema = Joi.object({
_id: Joi.object(),
event: Joi.string(),
name: Joi.string(),
data: Joi.object(),
userId: Joi.string(),
createdAt: new Date()


});

Analytic.payload = Joi.object({
event: Joi.string(),
name: Joi.string(),
data: Joi.object()
});

Analytic.indexes = [
{ key: { event: 1 } },
{ key : { email: 1 } }
];

module.exports = Analytic;


4 changes: 2 additions & 2 deletions server/models/user.js
Expand Up @@ -2,10 +2,10 @@
const Assert = require('assert');
const Bcrypt = require('bcrypt');
const Joi = require('joi');
const MongoModels = require('hicsail-mongo-models');
const AnchorModel = require('../anchor/anchor-model');


class User extends MongoModels {
class User extends AnchorModel {

static async generatePasswordHash(password) {

Expand Down

0 comments on commit 2c57de8

Please sign in to comment.