dobo 2.13.0 → 2.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/factory/model/_util.js +17 -1
- package/package.json +1 -1
- package/wiki/CHANGES.md +4 -0
|
@@ -236,6 +236,22 @@ export async function getMultiRefs (records = [], options = {}) {
|
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
+
export function parseNql (text) {
|
|
240
|
+
const sanitized = text.split('+').map(item => {
|
|
241
|
+
const [key, ...rest] = item.split(':').map(i => i.trim())
|
|
242
|
+
let value = rest.join(':')
|
|
243
|
+
const neg = value[1] === '-' ? '-' : ''
|
|
244
|
+
if ((value[0] === '{' || value[1] === '{') && value[value.length - 1] === '}') {
|
|
245
|
+
if (value[0] === '-') value = value.slice(1)
|
|
246
|
+
const items = value.slice(1, -1).split(',')
|
|
247
|
+
value = `${neg}>=${items[0]}+${key}:${neg}<=${items[1]}`
|
|
248
|
+
}
|
|
249
|
+
return `${key}:${value}`
|
|
250
|
+
}).join('+')
|
|
251
|
+
|
|
252
|
+
return nql(sanitized).parse()
|
|
253
|
+
}
|
|
254
|
+
|
|
239
255
|
export function buildFilterQuery (filter = {}) {
|
|
240
256
|
const { trim, find, isString, isPlainObject } = this.app.lib._
|
|
241
257
|
let query = filter.query ?? {}
|
|
@@ -244,7 +260,7 @@ export function buildFilterQuery (filter = {}) {
|
|
|
244
260
|
try {
|
|
245
261
|
query = trim(query)
|
|
246
262
|
if (query.startsWith('{')) q = JSON.parse(query) // JSON formatted query
|
|
247
|
-
else if (query.includes(':')) q =
|
|
263
|
+
else if (query.includes(':')) q = parseNql.call(this, query) // NQL
|
|
248
264
|
else {
|
|
249
265
|
let scanables = [...this.scanables]
|
|
250
266
|
if (scanables.length === 0) scanables = [...this.sortables]
|
package/package.json
CHANGED