diff --git a/ data-model.png b/ data-model.png new file mode 100644 index 000000000..43855b542 Binary files /dev/null and b/ data-model.png differ diff --git a/ data-model.xml b/ data-model.xml new file mode 100644 index 000000000..1597bf7d9 --- /dev/null +++ b/ data-model.xml @@ -0,0 +1 @@ +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+0TsuAOOYFdFvGPc5k2Me2Wsa+ZwkIty65A9hvnjTYh7RFwsuwZBDBTEfHHLdhPhPglbA661TEMhnFd1mqn7hewOuOIy1RWXlyDIkP8K1R3xRPl2uyZtwEWXqTo9dlt/otw/ZWPAVZelKyiRH6DCWcUfNaQBjSF5rKTLzHWHf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NgjG0yTdJ+FBA0aO6tfepWh67btnxEO+E+yqjqApvD8I5SHfC3Z1dSBP8f0hKPf4YjBPVr/BlW+gq985Mx7/Bw== \ No newline at end of file diff --git a/README.md b/README.md index 5f8b6d3d7..70e2d1110 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Runs Talk. `npm test` ### Lint -`npm lint` +`npm run lint` ### Docs `swagger.yaml` diff --git a/models/action.js b/models/action.js new file mode 100644 index 000000000..581108a71 --- /dev/null +++ b/models/action.js @@ -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; diff --git a/models/comment.js b/models/comment.js new file mode 100644 index 000000000..107708a3b --- /dev/null +++ b/models/comment.js @@ -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; diff --git a/models/user.js b/models/user.js new file mode 100644 index 000000000..d6b174075 --- /dev/null +++ b/models/user.js @@ -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;