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
}
resolveKnexQueryLog(): KnexQueryLog {
return make(NajsEloquent.QueryBuilder.KnexQueryLog, [])
}
}
resolveKnexQueryLog() {
return najs_binding_1.make(constants_2.NajsEloquent.QueryBuilder.KnexQueryLog, []);
}
}