PDA

View Full Version : [OPEN] [INFOREQ][PR4] Ext.model save, throws error



4CastRisk
16 Mar 2011, 8:58 AM
In ExtJS3, this stuff worked fine with records + stores - but in ExtJS4 throws an error.

I'm using CouchDB as a backend, and in some cases we do have associations of records which are fine, but also in some documents we want to store things like tags just as an array within the document. In the below example, this would be asset_tags, so no type is defined

The example here is:



Ext.regModel 'models.asset',
extend: 'models.base_model'
alias: 'AssetModel'
fields: [
{ name: 'location_reference', type: 'string' }
{ name: 'volume', type: 'int' }
{ name: 'has_backup', type: 'boolean' }
{ name: 'recovery_capibility' }
{ name: 'asset_tags'}
]

associations: [
{ type: 'belongsTo', model: 'app.models.role' , name: 'owner' }
{ type: 'belongsTo', model: 'app.models.role', name: 'delegate' }
{ type: 'belongsTo', model: 'app.models.office', name: 'location' }
{ type: 'belongsTo', model: 'app.models.office', name: 'backup_location' }
{ type: 'hasMany', model: 'app.models.process', name: 'processes' }
{ type: 'hasMany', model: 'app.models.category', name: 'categories' }
]


From base model it inherits some fields like _id and _rev and also the main proxy that is used (a custom DNode Proxy)

Next I create an empty asset:



mdl = Ext.ModelMgr.create
_id: ''
_rev: ''
name: 'New Asset'
type: 'Asset'
created: Date.now()
modified: Date.now()
asset_tags: []
, 'AssetModel'

mdl.save()


It then throws this error:

this.extractorFunctions[i] is not a function - which is in extractValues method.

Any ideas how to get around this with ExtJS4, or is this a bug? We can't store this value as a comma-seperated string as we need to do CouchDB views that search around this data.

evant
16 Mar 2011, 10:01 PM
Please post a test case:



Ext.regModel('Item', {
fields: ['foo', 'bar'],
proxy: {
type: 'ajax',
url: 'foo'
}
});

var rec = new Item({
foo: 'value',
bar: []
});
rec.save();