dynamic-record
Version:
A bare minimum Javascript implementation of the Active Record pattern
18 lines (17 loc) • 582 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DynamicCollection = void 0;
const DynamicCollection_1 = require("../DynamicCollection");
class DynamicCollection extends DynamicCollection_1.DynamicCollection {
constructor(Model, ...data) {
super(Model, ...data);
}
static fromArray(arr, Model) {
const result = arr.reduce((acc, el) => {
acc.push(new Model(el));
return acc;
}, new DynamicCollection(Model));
return result;
}
}
exports.DynamicCollection = DynamicCollection;