mirror of
https://github.com/wassname/talk.git
synced 2026-06-29 00:56:24 +08:00
a7e9c0c776
- Updated enum values to be uppercase - Updated services to expose service models - Updated models to only export the mongoose model - Moved all mongoose static methods over to new services - Updated tests to refelct new setup BREAKING - Status that were uppercased (caps) have caused issues with the admin pages
43 lines
683 B
JavaScript
43 lines
683 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,
|
|
metadata: Schema.Types.Mixed
|
|
}, {
|
|
timestamps: {
|
|
createdAt: 'created_at',
|
|
updatedAt: 'updated_at'
|
|
}
|
|
});
|
|
|
|
const Action = mongoose.model('Action', ActionSchema);
|
|
|
|
module.exports = Action;
|