Reputation: 341
I'm using Redux-ORM to store relational model data in a react project I'm building.
There are two models; Site and Document. The relationship between them is many-to-many. The relationship is defined in the Document Model.
export class Site extends Model {
static get fields() {
return {
id: attr(),
name: attr()
}
}
}
Site.modelName = 'Site'
export class Document extends Model {
static get fields() {
return {
id: attr(),
name: attr(),
site_ids: many({
to: 'Site',
as: 'sites',
relatedName: 'documents'
})
}
}
}
Document.modelName = 'Document'
All is working fine (add/update), except I can't delete a Document that has relationships:
Document.withId(action.documentId).delete()
Causes an error in Models.js line 734 "Uncaught (in promise) TypeError: this[key].clear is not a function"
devTools shows that 'this' = SessionBoundModel and 'key' "site_ids"
So it appears to be trying to run the .clear() function on an array. Has anyone else been able to implement deletes on many-to-many? Is my model wrong or is this a bug?
thanks
Upvotes: 1
Views: 167