waibu-rest-api 2.8.0 → 2.8.1
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/index.js +1 -0
- package/lib/route-by-model-builder.js +4 -2
- package/package.json +1 -1
- package/wiki/CHANGES.md +1 -0
package/index.js
CHANGED
|
@@ -143,6 +143,7 @@ async function factory (pkgName) {
|
|
|
143
143
|
const { each, keys, omit, get } = this.app.lib._
|
|
144
144
|
const cfg = this.config
|
|
145
145
|
const cfgWdb = this.app.waibuDb.config
|
|
146
|
+
if (!options.showWarnings) delete data.warnings
|
|
146
147
|
if (reply) {
|
|
147
148
|
reply.code(req.method.toUpperCase() === 'POST' ? 201 : 200)
|
|
148
149
|
if (cfgWdb.dbModel.dataOnly) {
|
|
@@ -35,13 +35,15 @@ async function routeByModelBuilder ({ file, dir, pathPrefix, ns, parent }) {
|
|
|
35
35
|
method: mapmethod,
|
|
36
36
|
handler: async function (req, reply) {
|
|
37
37
|
const helper = me.app.waibuDb[`${method === 'replace' ? 'update' : method}Record`]
|
|
38
|
-
|
|
38
|
+
const { fields } = getParams(req)
|
|
39
|
+
let count = true
|
|
39
40
|
let refs = []
|
|
40
41
|
const headers = parseObject(req.headers, { parseValue: true })
|
|
41
|
-
if (
|
|
42
|
+
if (headers['x-nocount']) count = false
|
|
42
43
|
if (isSet(headers['x-refs'])) refs = headers['x-refs']
|
|
43
44
|
if (typeof refs === 'string' && !['*', 'all'].includes(refs)) refs = [refs]
|
|
44
45
|
const options = { fields, count, refs, dynHooks: builder.hooks ?? [] }
|
|
46
|
+
if (headers['x-warnings']) options.showWarnings = true
|
|
45
47
|
options.hidden = builder.hidden ?? []
|
|
46
48
|
options.queryHandler = builder.queryHandler
|
|
47
49
|
if (method === 'replace') options.partial = false
|
package/package.json
CHANGED