Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected createDriver(model: Object, driverClass: string, isGuarded: boolean): Driver {
if (typeof this.driverInstances[driverClass] === 'undefined') {
this.driverInstances[driverClass] = make>(driverClass, [model, isGuarded])
// driver.createStaticMethods(Object.getPrototypeOf(model).constructor)
}
return this.driverInstances[driverClass]
}
createDriver(model, driverClass, isGuarded) {
if (typeof this.driverInstances[driverClass] === 'undefined') {
this.driverInstances[driverClass] = najs_binding_1.make(driverClass, [model, isGuarded]);
// driver.createStaticMethods(Object.getPrototypeOf(model).constructor)
}
return this.driverInstances[driverClass];
}
has(driver) {
newInstance(data) {
const instance = najs_binding_1.make(this.getClassName());
instance.fillable = this.fillable;
instance.guarded = this.guarded;
return instance.initialize(data);
}
newCollection(dataset) {
getModelByNameOrDefinition(model) {
if (typeof model === 'function') {
return Reflect.construct(model, []);
}
return najs_binding_1.make(model);
}
}
getModelByNameOrDefinition(model: string | Function): NajsEloquent.Model.IModel {
if (typeof model === 'function') {
return Reflect.construct(model as Function, [])
}
return make(model)
}
}
createRelationDataBucketIfNeeded() {
if (!this.relationDataBucket) {
this.relationDataBucket = najs_binding_1.make(constants_1.NajsEloquent.Relation.RelationDataBucket, []);
}
return this.relationDataBucket.register(this.recordName, this.modelName);
}
async first(id) {
setupRelation(className: string, setup: () => NajsEloquent.Relation.IRelation) {
if (this.isSample) {
return make(className, [this.rootModel, this.name])
}
if (!this.relation) {
this.relation = setup()
}
return this.relation
}
najs_binding_1.register(driver);
}
this.drivers[name] = {
driverClassName: najs_binding_1.getClassName(driver),
isDefault: isDefault
};
return this;
}
bind(model, driver) {
this.binding[model] = driver;
return this;
}
}
DriverProvider.className = constants_1.NajsEloquent.Provider.DriverProvider;
exports.DriverProvider = DriverProvider;
najs_binding_1.register(DriverProvider, constants_1.NajsEloquent.Provider.DriverProvider);
if (typeof driver === 'function') {
register(driver)
}
this.drivers[name] = {
driverClassName: getClassName(driver),
isDefault: isDefault
}
return this
}
bind(model: string, driver: string): this {
this.binding[model] = driver
return this
}
}
register(DriverProvider, NajsEloquent.Provider.DriverProvider)
index: count
};
return this;
}
bind(model, component) {
if (typeof this.binding[model] === 'undefined') {
this.binding[model] = [];
}
this.binding[model].push(component);
this.binding[model] = functions_1.array_unique(this.binding[model]);
return this;
}
}
ComponentProvider.className = constants_1.NajsEloquent.Provider.ComponentProvider;
exports.ComponentProvider = ComponentProvider;
najs_binding_1.register(ComponentProvider);