|
|
@ -42,6 +42,7 @@ import { NcError } from '../../../../meta/helpers/catchError'; |
|
|
|
import { customAlphabet } from 'nanoid'; |
|
|
|
import { customAlphabet } from 'nanoid'; |
|
|
|
import DOMPurify from 'isomorphic-dompurify'; |
|
|
|
import DOMPurify from 'isomorphic-dompurify'; |
|
|
|
import { sanitize, unsanitize } from './helpers/sanitize'; |
|
|
|
import { sanitize, unsanitize } from './helpers/sanitize'; |
|
|
|
|
|
|
|
import { fisherYatesShuffle } from '../../../../meta/helpers/shuffleHelper'; |
|
|
|
|
|
|
|
|
|
|
|
const GROUP_COL = '__nc_group_id'; |
|
|
|
const GROUP_COL = '__nc_group_id'; |
|
|
|
|
|
|
|
|
|
|
@ -247,8 +248,10 @@ class BaseModelSqlv2 { |
|
|
|
|
|
|
|
|
|
|
|
if (!ignoreFilterSort) applyPaginate(qb, rest); |
|
|
|
if (!ignoreFilterSort) applyPaginate(qb, rest); |
|
|
|
const proto = await this.getProto(); |
|
|
|
const proto = await this.getProto(); |
|
|
|
const data = await this.extractRawQueryAndExec(qb); |
|
|
|
let data = await this.extractRawQueryAndExec(qb); |
|
|
|
|
|
|
|
if (+rest?.shuffle) { |
|
|
|
|
|
|
|
data = fisherYatesShuffle(data); |
|
|
|
|
|
|
|
} |
|
|
|
return data?.map((d) => { |
|
|
|
return data?.map((d) => { |
|
|
|
d.__proto__ = proto; |
|
|
|
d.__proto__ = proto; |
|
|
|
return d; |
|
|
|
return d; |
|
|
@ -354,8 +357,11 @@ class BaseModelSqlv2 { |
|
|
|
qb.groupBy(args.column_name); |
|
|
|
qb.groupBy(args.column_name); |
|
|
|
if (sorts) await sortV2(sorts, qb, this.dbDriver); |
|
|
|
if (sorts) await sortV2(sorts, qb, this.dbDriver); |
|
|
|
applyPaginate(qb, rest); |
|
|
|
applyPaginate(qb, rest); |
|
|
|
|
|
|
|
let data = await qb; |
|
|
|
return await qb; |
|
|
|
if (+rest?.shuffle) { |
|
|
|
|
|
|
|
data = fisherYatesShuffle(data); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return data; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async multipleHmList({ colId, ids }, args?: { limit?; offset? }) { |
|
|
|
async multipleHmList({ colId, ids }, args?: { limit?; offset? }) { |
|
|
@ -861,8 +867,11 @@ class BaseModelSqlv2 { |
|
|
|
applyPaginate(qb, args); |
|
|
|
applyPaginate(qb, args); |
|
|
|
|
|
|
|
|
|
|
|
const proto = await childModel.getProto(); |
|
|
|
const proto = await childModel.getProto(); |
|
|
|
|
|
|
|
let data = await qb; |
|
|
|
return (await qb).map((c) => { |
|
|
|
if (+args?.shuffle) { |
|
|
|
|
|
|
|
data = fisherYatesShuffle(data); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return data.map((c) => { |
|
|
|
c.__proto__ = proto; |
|
|
|
c.__proto__ = proto; |
|
|
|
return c; |
|
|
|
return c; |
|
|
|
}); |
|
|
|
}); |
|
|
@ -954,8 +963,11 @@ class BaseModelSqlv2 { |
|
|
|
applyPaginate(qb, args); |
|
|
|
applyPaginate(qb, args); |
|
|
|
|
|
|
|
|
|
|
|
const proto = await childModel.getProto(); |
|
|
|
const proto = await childModel.getProto(); |
|
|
|
|
|
|
|
let data = await this.extractRawQueryAndExec(qb); |
|
|
|
return (await this.extractRawQueryAndExec(qb)).map((c) => { |
|
|
|
if (+args?.shuffle) { |
|
|
|
|
|
|
|
data = fisherYatesShuffle(data); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return data.map((c) => { |
|
|
|
c.__proto__ = proto; |
|
|
|
c.__proto__ = proto; |
|
|
|
return c; |
|
|
|
return c; |
|
|
|
}); |
|
|
|
}); |
|
|
@ -1047,7 +1059,11 @@ class BaseModelSqlv2 { |
|
|
|
applyPaginate(qb, args); |
|
|
|
applyPaginate(qb, args); |
|
|
|
|
|
|
|
|
|
|
|
const proto = await parentModel.getProto(); |
|
|
|
const proto = await parentModel.getProto(); |
|
|
|
return (await this.extractRawQueryAndExec(qb)).map((c) => { |
|
|
|
let data = await this.extractRawQueryAndExec(qb); |
|
|
|
|
|
|
|
if (+args?.shuffle) { |
|
|
|
|
|
|
|
data = fisherYatesShuffle(data); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return data.map((c) => { |
|
|
|
c.__proto__ = proto; |
|
|
|
c.__proto__ = proto; |
|
|
|
return c; |
|
|
|
return c; |
|
|
|
}); |
|
|
|
}); |
|
|
@ -1227,6 +1243,7 @@ class BaseModelSqlv2 { |
|
|
|
const obj: XcFilter = {}; |
|
|
|
const obj: XcFilter = {}; |
|
|
|
obj.where = args.where || args.w || ''; |
|
|
|
obj.where = args.where || args.w || ''; |
|
|
|
obj.having = args.having || args.h || ''; |
|
|
|
obj.having = args.having || args.h || ''; |
|
|
|
|
|
|
|
obj.shuffle = args.shuffle || args.r || ''; |
|
|
|
obj.condition = args.condition || args.c || {}; |
|
|
|
obj.condition = args.condition || args.c || {}; |
|
|
|
obj.conditionGraph = args.conditionGraph || {}; |
|
|
|
obj.conditionGraph = args.conditionGraph || {}; |
|
|
|
obj.limit = Math.max( |
|
|
|
obj.limit = Math.max( |
|
|
|