mirror of
https://github.com/wassname/talk.git
synced 2026-07-17 11:33:39 +08:00
Added asset settings + improved tests for routes
This commit is contained in:
+18
-1
@@ -1,7 +1,8 @@
|
||||
const mongoose = require('../mongoose');
|
||||
const uuid = require('uuid');
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const uuid = require('uuid');
|
||||
|
||||
const AssetSchema = new Schema({
|
||||
id: {
|
||||
type: String,
|
||||
@@ -22,6 +23,10 @@ const AssetSchema = new Schema({
|
||||
type: Date,
|
||||
default: null
|
||||
},
|
||||
settings: {
|
||||
type: Schema.Types.Mixed,
|
||||
default: null
|
||||
},
|
||||
title: String,
|
||||
description: String,
|
||||
image: String,
|
||||
@@ -90,6 +95,18 @@ AssetSchema.statics.findOrCreateByUrl = (url) => Asset.findOneAndUpdate({url}, {
|
||||
setDefaultsOnInsert: true
|
||||
});
|
||||
|
||||
/**
|
||||
* Updates the settings for the asset.
|
||||
* @param {[type]} id [description]
|
||||
* @param {[type]} settings [description]
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
AssetSchema.statics.overrideSettings = (id, settings) => Asset.update({id}, {
|
||||
$set: {
|
||||
settings
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Finds assets matching keywords on the model. If `value` is an empty string,
|
||||
* then it will not even perform a text search query.
|
||||
|
||||
@@ -9,6 +9,7 @@ const SALT_ROUNDS = 10;
|
||||
|
||||
// USER_ROLES is the array of roles that is permissible as a user role.
|
||||
const USER_ROLES = [
|
||||
'',
|
||||
'admin',
|
||||
'moderator'
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user