|
|
|
@ -123,12 +123,13 @@ class BaseModelSqlv2 {
|
|
|
|
|
sort?: string | string[]; |
|
|
|
|
} = {} |
|
|
|
|
): Promise<any> { |
|
|
|
|
const { where, ...rest } = this._getListArgs(args as any); |
|
|
|
|
const qb = this.dbDriver(this.tnPath); |
|
|
|
|
await this.selectObject({ qb }); |
|
|
|
|
|
|
|
|
|
const aliasColObjMap = await this.model.getAliasColObjMap(); |
|
|
|
|
const sorts = extractSortsObject(args?.sort, aliasColObjMap); |
|
|
|
|
const filterObj = extractFilterFromXwhere(args?.where, aliasColObjMap); |
|
|
|
|
const sorts = extractSortsObject(rest?.sort, aliasColObjMap); |
|
|
|
|
const filterObj = extractFilterFromXwhere(where, aliasColObjMap); |
|
|
|
|
|
|
|
|
|
await conditionV2( |
|
|
|
|
[ |
|
|
|
@ -183,8 +184,8 @@ class BaseModelSqlv2 {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const aliasColObjMap = await this.model.getAliasColObjMap(); |
|
|
|
|
let sorts = extractSortsObject(args?.sort, aliasColObjMap); |
|
|
|
|
const filterObj = extractFilterFromXwhere(args?.where, aliasColObjMap); |
|
|
|
|
let sorts = extractSortsObject(rest?.sort, aliasColObjMap); |
|
|
|
|
const filterObj = extractFilterFromXwhere(where, aliasColObjMap); |
|
|
|
|
// todo: replace with view id
|
|
|
|
|
if (!ignoreFilterSort && this.viewId) { |
|
|
|
|
await conditionV2( |
|
|
|
@ -344,9 +345,9 @@ class BaseModelSqlv2 {
|
|
|
|
|
|
|
|
|
|
const aliasColObjMap = await this.model.getAliasColObjMap(); |
|
|
|
|
|
|
|
|
|
const sorts = extractSortsObject(args?.sort, aliasColObjMap); |
|
|
|
|
const sorts = extractSortsObject(rest?.sort, aliasColObjMap); |
|
|
|
|
|
|
|
|
|
const filterObj = extractFilterFromXwhere(args?.where, aliasColObjMap); |
|
|
|
|
const filterObj = extractFilterFromXwhere(where, aliasColObjMap); |
|
|
|
|
await conditionV2( |
|
|
|
|
[ |
|
|
|
|
new Filter({ |
|
|
|
@ -365,8 +366,9 @@ class BaseModelSqlv2 {
|
|
|
|
|
return data; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async multipleHmList({ colId, ids }, args?: { limit?; offset? }) { |
|
|
|
|
async multipleHmList({ colId, ids }, args: { limit?; offset? } = {}) { |
|
|
|
|
try { |
|
|
|
|
const { where, ...rest } = this._getListArgs(args as any); |
|
|
|
|
// todo: get only required fields
|
|
|
|
|
|
|
|
|
|
// const { cn } = this.hasManyRelations.find(({ tn }) => tn === child) || {};
|
|
|
|
@ -406,8 +408,8 @@ class BaseModelSqlv2 {
|
|
|
|
|
.where(_wherePk(parentTable.primaryKeys, p)) |
|
|
|
|
); |
|
|
|
|
// todo: sanitize
|
|
|
|
|
query.limit(args?.limit || 20); |
|
|
|
|
query.offset(args?.offset || 0); |
|
|
|
|
query.limit(+rest?.limit || 20); |
|
|
|
|
query.offset(+rest?.offset || 0); |
|
|
|
|
|
|
|
|
|
return this.isSqlite ? this.dbDriver.select().from(query) : query; |
|
|
|
|
}), |
|
|
|
@ -478,8 +480,9 @@ class BaseModelSqlv2 {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async hmList({ colId, id }, args?: { limit?; offset? }) { |
|
|
|
|
async hmList({ colId, id }, args: { limit?; offset? } = {}) { |
|
|
|
|
try { |
|
|
|
|
const { where, ...rest } = this._getListArgs(args as any); |
|
|
|
|
// todo: get only required fields
|
|
|
|
|
|
|
|
|
|
const relColumn = (await this.model.getColumns()).find( |
|
|
|
@ -510,8 +513,8 @@ class BaseModelSqlv2 {
|
|
|
|
|
.where(_wherePk(parentTable.primaryKeys, id)) |
|
|
|
|
); |
|
|
|
|
// todo: sanitize
|
|
|
|
|
qb.limit(args?.limit || 20); |
|
|
|
|
qb.offset(args?.offset || 0); |
|
|
|
|
qb.limit(+rest?.limit || 20); |
|
|
|
|
qb.offset(+rest?.offset || 0); |
|
|
|
|
|
|
|
|
|
await childModel.selectObject({ qb }); |
|
|
|
|
|
|
|
|
@ -568,7 +571,8 @@ class BaseModelSqlv2 {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public async multipleMmList({ colId, parentIds }, args?: { limit; offset }) { |
|
|
|
|
public async multipleMmList({ colId, parentIds }, args: { limit?; offset? } = {}) { |
|
|
|
|
const { where, ...rest } = this._getListArgs(args as any); |
|
|
|
|
const relColumn = (await this.model.getColumns()).find( |
|
|
|
|
(c) => c.id === colId |
|
|
|
|
); |
|
|
|
@ -609,8 +613,8 @@ class BaseModelSqlv2 {
|
|
|
|
|
.select(this.dbDriver.raw('? as ??', [id, GROUP_COL])); |
|
|
|
|
|
|
|
|
|
// todo: sanitize
|
|
|
|
|
query.limit(args?.limit || 20); |
|
|
|
|
query.offset(args?.offset || 0); |
|
|
|
|
query.limit(+rest?.limit || 20); |
|
|
|
|
query.offset(+rest?.offset || 0); |
|
|
|
|
|
|
|
|
|
return this.isSqlite ? this.dbDriver.select().from(query) : query; |
|
|
|
|
}), |
|
|
|
@ -637,7 +641,8 @@ class BaseModelSqlv2 {
|
|
|
|
|
return parentIds.map((id) => gs[id] || []); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public async mmList({ colId, parentId }, args?: { limit; offset }) { |
|
|
|
|
public async mmList({ colId, parentId }, args: { limit?; offset? } = {}) { |
|
|
|
|
const { where, ...rest } = this._getListArgs(args as any); |
|
|
|
|
const relColumn = (await this.model.getColumns()).find( |
|
|
|
|
(c) => c.id === colId |
|
|
|
|
); |
|
|
|
@ -673,8 +678,8 @@ class BaseModelSqlv2 {
|
|
|
|
|
|
|
|
|
|
await childModel.selectObject({ qb }); |
|
|
|
|
// todo: sanitize
|
|
|
|
|
qb.limit(args?.limit || 20); |
|
|
|
|
qb.offset(args?.offset || 0); |
|
|
|
|
qb.limit(+rest?.limit || 20); |
|
|
|
|
qb.offset(+rest?.offset || 0); |
|
|
|
|
|
|
|
|
|
const children = await this.extractRawQueryAndExec(qb); |
|
|
|
|
const proto = await ( |
|
|
|
|