Fixed i18n population because mongoose has problems with empty objects.

This commit is contained in:
Scott Erickson 2014-07-12 09:42:50 -07:00
parent 89dc724d31
commit 8cb7cd770c
2 changed files with 2 additions and 2 deletions

View file

@ -237,7 +237,7 @@ class CocoModel extends Backbone.Model
data ?= $.extend true, {}, @attributes
schema ?= @schema() or {}
if schema.properties?.i18n and _.isPlainObject(data) and not data.i18n?
data.i18n = {}
data.i18n = {'-':'-'} # mongoose doesn't work with empty objects
sum += 1
if _.isPlainObject data

View file

@ -46,7 +46,7 @@ db.users.find({anonymous:false}, params).sort({_id:1}).forEach(function (user) {
}
update.slug = slug;
slugs[slug] = user.name;
if(user.slug) return;
if(user.slug === slug) return;
print(_.str.sprintf('Setting user %s (%s) to slug %s with update %s', user.name, user.dateCreated, slug, JSON.stringify({$set:update})));
var res = db.users.update({_id:user._id}, {$set:update});
if(res.hasWriteError()) {