[#1444] add filters back to use schema. Allow editing of top-level tags

object in PUT /user, WARNING! We want to get away from that ASAP and
instead have a nested resource for managing tags. Set default task tags
if not present, will revisit after tasks are a subdoc too
This commit is contained in:
Tyler Renelle
2013-09-08 23:28:34 -04:00
parent 9690c7112f
commit f99b496a29
4 changed files with 9 additions and 7 deletions

View File

@@ -57,7 +57,7 @@ var UserSchema = new Schema({
dailyIds: Array,
todoIds: Array,
rewardIds: Array,
/* Removed `filters`, no longer persisting to the database*/
filters: {type: Schema.Types.Mixed, 'default': {}},
flags: {
ads: String,
@@ -218,6 +218,7 @@ function transformTaskLists(doc) {
_.each(['habit', 'daily', 'todo', 'reward'], function(type) {
// we use _.transform instead of a simple _.where in order to maintain sort-order
doc[type + "s"] = _.reduce(doc[type + "Ids"], function(m, tid) {
if (!doc.tasks[tid].tags) doc.tasks[tid].tags = {}; // FIXME remove this when we switch tasks to subdocs and can define tags default in schema
m.push(doc.tasks[tid]);
return m;
}, []);
@@ -238,7 +239,7 @@ UserSchema.methods.toJSON = function() {
delete doc["#{type}Ids"]
});
delete doc.tasks
doc.filters = {};
//doc.filters = {};
return doc;
};