Let all the new CollectionModels use AbstractCollectionModel

This commit is contained in:
djmaze
2020-09-16 16:33:53 +02:00
parent 086a2c1927
commit 71f6fb25e5
5 changed files with 39 additions and 44 deletions

View File

@@ -0,0 +1,15 @@
export class AbstractCollectionModel extends Array
{
constructor(props) {
super();
props && Object.entries(props).forEach(([key, value]) => '@' !== key[0] && (this[key] = value));
// props[@Count]
}
static getFromJSON(object, name) {
return object && 'Collection/'+name === object['@Object'] && Array.isArray(object['@Collection'])
? object['@Collection']
: null;
}
}