waibu-db 2.1.1 → 2.1.3
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/extend/waibuRestApi/route/@model/find.js +1 -10
- package/lib/prep-crud.js +10 -2
- package/package.json +1 -1
- package/wiki/CHANGES.md +4 -0
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
async function find (req, reply) {
|
|
2
|
-
|
|
3
|
-
const { parseObject } = this.app.lib
|
|
4
|
-
let { fields, count } = this.getParams(req)
|
|
5
|
-
let rels = []
|
|
6
|
-
const headers = parseObject(req.headers, { parseValue: true })
|
|
7
|
-
if (isSet(headers['x-count'])) count = headers['x-count']
|
|
8
|
-
if (isSet(headers['x-rels'])) rels = headers['x-rels']
|
|
9
|
-
if (typeof rels === 'string' && !['*', 'all'].includes(rels)) rels = [rels]
|
|
10
|
-
const options = { fields, count, rels }
|
|
11
|
-
return await this.findRecord({ req, reply, options })
|
|
2
|
+
return await this.findRecord({ req, reply })
|
|
12
3
|
}
|
|
13
4
|
|
|
14
5
|
export default find
|
package/lib/prep-crud.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
async function prepCrud ({ model, body, id, req, reply, options = {}, args }) {
|
|
2
|
+
const { parseObject, isSet } = this.app.lib.aneka
|
|
2
3
|
const { parseFilter } = this.app.waibu
|
|
3
4
|
const { pascalCase } = this.app.lib.aneka
|
|
4
|
-
const { cloneDeep, has
|
|
5
|
+
const { cloneDeep, has } = this.app.lib._
|
|
5
6
|
const cfgWeb = this.app.waibu.getConfig()
|
|
6
7
|
const opts = cloneDeep(options)
|
|
7
8
|
const params = this.getParams(req, ...args)
|
|
@@ -18,6 +19,13 @@ async function prepCrud ({ model, body, id, req, reply, options = {}, args }) {
|
|
|
18
19
|
stats = stats ?? req.query.stats
|
|
19
20
|
mimeType = mimeType ?? req.query.mimeType
|
|
20
21
|
|
|
22
|
+
let refs = []
|
|
23
|
+
const headers = parseObject(req.headers, { parseValue: true })
|
|
24
|
+
if (isSet(headers['x-count'])) options.count = headers['x-count']
|
|
25
|
+
if (isSet(headers['x-refs'])) refs = headers['x-refs']
|
|
26
|
+
if (typeof refs === 'string' && !['*', 'all'].includes(refs)) refs = [refs]
|
|
27
|
+
if (refs.length > 0) options.refs = refs
|
|
28
|
+
|
|
21
29
|
const recId = id ?? params.id ?? req.query.id
|
|
22
30
|
model = model ?? pascalCase(params.model)
|
|
23
31
|
const mdl = this.app.dobo.getModel(model)
|
|
@@ -25,7 +33,7 @@ async function prepCrud ({ model, body, id, req, reply, options = {}, args }) {
|
|
|
25
33
|
|
|
26
34
|
opts.bboxLatField = req.query[cfgWeb.qsKey.bboxLatField]
|
|
27
35
|
opts.bboxLngField = req.query[cfgWeb.qsKey.bboxLngField]
|
|
28
|
-
const filter =
|
|
36
|
+
const filter = parseFilter(req)
|
|
29
37
|
if (options.query) filter.query = cloneDeep(options.query)
|
|
30
38
|
if (options.limit) filter.limit = options.limit
|
|
31
39
|
if (options.sort) filter.sort = options.sort
|
package/package.json
CHANGED