mirror of
https://github.com/wassname/talk.git
synced 2026-06-29 04:28:20 +08:00
49 lines
872 B
JavaScript
49 lines
872 B
JavaScript
const mongoose = require('../services/mongoose');
|
|
const uuid = require('uuid');
|
|
const Schema = mongoose.Schema;
|
|
|
|
const ACTION_TYPES = [
|
|
'LIKE',
|
|
'FLAG'
|
|
];
|
|
|
|
const ITEM_TYPES = [
|
|
'ASSETS',
|
|
'COMMENTS',
|
|
'USERS'
|
|
];
|
|
|
|
const ActionSchema = new Schema({
|
|
id: {
|
|
type: String,
|
|
default: uuid.v4,
|
|
unique: true
|
|
},
|
|
action_type: {
|
|
type: String,
|
|
enum: ACTION_TYPES
|
|
},
|
|
item_type: {
|
|
type: String,
|
|
enum: ITEM_TYPES
|
|
},
|
|
item_id: String,
|
|
user_id: String,
|
|
|
|
// The element that summaries will additionally group on in addtion to their action_type, item_type, and
|
|
// item_id.
|
|
group_id: String,
|
|
|
|
// Additional metadata stored on the field.
|
|
metadata: Schema.Types.Mixed
|
|
}, {
|
|
timestamps: {
|
|
createdAt: 'created_at',
|
|
updatedAt: 'updated_at'
|
|
}
|
|
});
|
|
|
|
const Action = mongoose.model('Action', ActionSchema);
|
|
|
|
module.exports = Action;
|