Trying to better get around mongoose stripping out empty i18n objects.
This commit is contained in:
parent
ee95e4e450
commit
7477633909
2 changed files with 6 additions and 1 deletions
app
|
@ -274,7 +274,7 @@ class CocoModel extends Backbone.Model
|
||||||
schema ?= @schema() or {}
|
schema ?= @schema() or {}
|
||||||
addedI18N = false
|
addedI18N = false
|
||||||
if schema.properties?.i18n and _.isPlainObject(data) and not data.i18n?
|
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
|
sum += 1
|
||||||
addedI18N = true
|
addedI18N = true
|
||||||
|
|
||||||
|
|
|
@ -266,6 +266,11 @@ class InternationalizationNode extends TreemaNode.nodeMap.object
|
||||||
res = super(arguments...)
|
res = super(arguments...)
|
||||||
res = (r for r in res when r[0] isnt '-')
|
res = (r for r in res when r[0] isnt '-')
|
||||||
res
|
res
|
||||||
|
|
||||||
|
populateData: ->
|
||||||
|
super()
|
||||||
|
if Object.keys(@data).length is 0
|
||||||
|
@data['-'] = {'-':'-'} # also to get around mongoose bug
|
||||||
|
|
||||||
getChildSchema: (key) ->
|
getChildSchema: (key) ->
|
||||||
#construct the child schema here
|
#construct the child schema here
|
||||||
|
|
Reference in a new issue