Open blloyd75 opened 9 years ago
I don't understand the problem. For untyped map attribute, you can not only use plain object, like this
var M = Model.extend({
defaults : {
yourMap : {}
}
})
but you can use every object constructor as a type. If plain object is not suitable for you for some reason, create your own object constructor for your map and go ahead.
var M = Model.extend({
defaults : {
yourMap : YourMap
}
})
:)
And yes, in contrast to plain Backbone, models in NestedTypes cannot be used as maps. Separate Map type can be created, however, we didn't needed it yet. Because all rare cases maps are needed can be handled with plain objects and custom types. So, I may do it in spare time.
With the current implementation, maps are not easily supported. A traditional javascript object or backbone object easily implements the map<string, value> model. However, nestedTypes cannot handle a typed map, where the attribute names may be random strings but the value is a fixed type.
Code like myObj[key].refnum is valid JavaScript, very useful, but cannot be easily done through the nestedTypes framework. Untyped maps can be used as a value for a field, but since field names MUST be predefined for an object, the closest to this structure that can be done is an object with a Collection of sub-objects where the key is an attribute of the sub-object.