|
|
@ -130,10 +130,24 @@ class BaseModelSqlv2 { |
|
|
|
autoBind(this); |
|
|
|
autoBind(this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async readByPk(id?: any, validateFormula = false): Promise<any> { |
|
|
|
public async readByPk( |
|
|
|
|
|
|
|
id?: any, |
|
|
|
|
|
|
|
validateFormula = false, |
|
|
|
|
|
|
|
query: any = {}, |
|
|
|
|
|
|
|
): Promise<any> { |
|
|
|
const qb = this.dbDriver(this.tnPath); |
|
|
|
const qb = this.dbDriver(this.tnPath); |
|
|
|
|
|
|
|
|
|
|
|
await this.selectObject({ qb, validateFormula }); |
|
|
|
const { ast, dependencyFields } = await getAst({ |
|
|
|
|
|
|
|
query, |
|
|
|
|
|
|
|
model: this.model, |
|
|
|
|
|
|
|
view: this.viewId && (await View.get(this.viewId)), |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await this.selectObject({ |
|
|
|
|
|
|
|
...(dependencyFields ?? {}), |
|
|
|
|
|
|
|
qb, |
|
|
|
|
|
|
|
validateFormula, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
qb.where(_wherePk(this.model.primaryKeys, id)); |
|
|
|
qb.where(_wherePk(this.model.primaryKeys, id)); |
|
|
|
|
|
|
|
|
|
|
@ -153,14 +167,7 @@ class BaseModelSqlv2 { |
|
|
|
data.__proto__ = proto; |
|
|
|
data.__proto__ = proto; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// retrieve virtual column data as well
|
|
|
|
return data ? await nocoExecute(ast, data, {}, query) : {}; |
|
|
|
const project = await Project.get(this.model.project_id); |
|
|
|
|
|
|
|
const { model, view } = await getViewAndModelByAliasOrId({ |
|
|
|
|
|
|
|
projectName: project.title, |
|
|
|
|
|
|
|
tableName: this.model.title, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
const { ast } = await getAst({ model, view }); |
|
|
|
|
|
|
|
return data ? await nocoExecute(ast, data, {}) : {}; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async exist(id?: any): Promise<any> { |
|
|
|
public async exist(id?: any): Promise<any> { |
|
|
|