Trying to better get around mongoose stripping out empty i18n objects.

This commit is contained in:
Scott Erickson 2014-10-28 11:18:36 -07:00
parent ee95e4e450
commit 7477633909
2 changed files with 6 additions and 1 deletions

View file

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

View file

@ -266,6 +266,11 @@ class InternationalizationNode extends TreemaNode.nodeMap.object
res = super(arguments...)
res = (r for r in res when r[0] isnt '-')
res
populateData: ->
super()
if Object.keys(@data).length is 0
@data['-'] = {'-':'-'} # also to get around mongoose bug
getChildSchema: (key) ->
#construct the child schema here