Merge pull request #2 from coralproject/data-model

Adding a draft for models.
This commit is contained in:
Gabriela Rodríguez Berón
2016-11-02 15:43:17 -07:00
committed by GitHub
6 changed files with 118 additions and 1 deletions
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

+1
View File
@@ -0,0 +1 @@
<mxfile userAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36" version="5.7.1.2" editor="www.draw.io" type="device"><diagram>7Zxbb6M4FIB/TV5WmgjMNY+TtLP70JWqrVa781Q54IB3DI7AmTTz69cGc3VI0iYwKEMVVfHh2Bh/to99jsnMWEVvvydwG/5JfURmQPPfZsbDDABnofH/QnDIBZbr5IIgwX4u0ivBC/6BpFDmC3bYR2lDkVFKGN42hR6NY+SxhgwmCd031TaUNO+6hQFSBC8eJKr0H+yzMJe6llbJ/0A4CIs765q8sobetyChu1jebwaMTfaXX45gUZbUT0Po031NZDzOjFVCKcu/RW8rRETTFs2W5/vScbWsd4JidlEGK8/xHZKdfPYVjSKRO68fOxRtku5xRGDMU8uQRYQLdf51Q2P2IpU0nvZCTPwneKA7cf+U8fYoUsuQJvgH14dFZn45YZI+sEVpmJAVJTThgpjm9yozvYjC5G0SlPJsz8Vz6qXoCaasqAolBG5TvM4qJ1QimAQ4XlLGaCSViqf6UrtzBc1YyuZBCUNvnW2sl+T4gEA0Qiw5cBWZARgSthwMjmzzfdWzdFOqhLVeBVwphLI3B2XRFVH+RULtAGwrgPmlNlv+cKzJNWUJ/YZaLI7ggQQHMU8StBEliIbCfBx9lmJGt6KwLfRwHDxlOg9mJflLPq0Q7UPM0AuXizrt+bTCZZSXtyHZAAmx76NYcKYMMrgue9yW4phlLWQt+Ye32UqbWzOLP9eKp/UqzT9CPWErGvPngzjjh3iP2SPRay6EbR2nLekC+0K69g3gOgrcNfUPE97+8FpgOLyGqeCFaYrY6zSC+0TsuAOOYFdFvGPc5k2Me2Ws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cbo7G3aaUBard8a07nOcWxqtEQfrP2Z9nH72o7rzsf3oRwCr/ufP2QsrCvcpenS6Z3SOarMF8+KXgovTmtcsURw1NjgFj67yRXaN+Z8QPHLUXTk7bKegUY94hwwaOeqmnrdh9Dox7pfxkDEj58iPNgjG0yTdJ+FBA0aO6tfepWh67btnxEO+E+yqjqApvD8I5SHfC3Z1dSBP8f0hKPf4YjBPVr/BlW+gq985Mx7/Bw==</diagram></mxfile>
+1 -1
View File
@@ -12,7 +12,7 @@ Runs Talk.
`npm test`
### Lint
`npm lint`
`npm run lint`
### Docs
`swagger.yaml`
+35
View File
@@ -0,0 +1,35 @@
'use strict';
const mongoose = require('../mongoose');
const uuid = require('uuid');
const Schema = mongoose.Schema;
const ActionSchema = new Schema({
id: {
type: String,
default: uuid.v4,
unique: true
},
action_type: String,
item_type: String,
item_id: String,
user_id: String
},{
_id: false,
timestamps: {
createdAt: 'created_at',
updatedAt: 'updated_at'
}
});
/**
* Finds an action by the id.
* @param {String} id identifier of the action (uuid)
*/
ActionSchema.statics.findById = function(id) {
return Action.findOne({id});
};
const Action = mongoose.model('Action', ActionSchema);
module.exports = Action;
+44
View File
@@ -0,0 +1,44 @@
'use strict';
const mongoose = require('../mongoose');
const uuid = require('uuid');
const Schema = mongoose.Schema;
const CommentSchema = new Schema({
id: {
type: String,
default: uuid.v4,
unique: true
},
body: {
type: String,
required: [true, 'The body is required.'],
minlength: 50
},
asset_id: String,
author_id: String,
status: {
type: String,
enum: ['accepted', 'rejected', ''],
default: ''
},
parent_id: String
},{
_id: false,
timestamps: {
createdAt: 'created_at',
updatedAt: 'updated_at'
}
});
/**
* Finds a comment by the id.
* @param {String} id identifier of the comment (uuid)
*/
CommentSchema.statics.findById = function(id) {
return Comment.findOne({id});
};
const Comment = mongoose.model('Comment', CommentSchema);
module.exports = Comment;
+37
View File
@@ -0,0 +1,37 @@
'use strict';
const mongoose = require('../mongoose');
const uuid = require('uuid');
const Schema = mongoose.Schema;
const UserProfileSchema = new Schema({
id: {
type: String,
default: uuid.v4,
unique: true
},
display_name: String,
auth_user_id: String
},{
_id: false,
timestamps: {
createdAt: 'created_at',
updatedAt: 'updated_at'
}
});
/**
* Finds a user by the id.
* @param {String} id identifier of the user (uuid)
*/
UserProfileSchema.statics.findById = function(id) {
return UserProfile.findOne({id});
};
// TO DO: methods
// modifications to user as statics
// find by auth user id
const UserProfile = mongoose.model('UserProfile', UserProfileSchema);
module.exports = UserProfile;