mirror of
https://github.com/wassname/talk.git
synced 2026-06-30 01:58:00 +08:00
36 lines
659 B
JavaScript
36 lines
659 B
JavaScript
'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;
|