Added asset settings + improved tests for routes

This commit is contained in:
Wyatt Johnson
2016-11-29 10:01:52 -07:00
parent 735f2d09ad
commit ac17fc2cc6
13 changed files with 401 additions and 407 deletions
+18 -1
View File
@@ -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.
+1
View File
@@ -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'
];