dobo 1.0.4 → 1.0.5
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.
|
@@ -8,12 +8,13 @@ async function findOne (name, filter = {}, opts = {}) {
|
|
|
8
8
|
const options = cloneDeep(omit(opts, ['req']))
|
|
9
9
|
options.req = opts.req
|
|
10
10
|
options.dataOnly = options.dataOnly ?? true
|
|
11
|
-
|
|
11
|
+
let { fields, dataOnly, noHook, noCache, hidden, forceNoHidden } = options
|
|
12
12
|
await this.modelExists(name, true)
|
|
13
13
|
filter.limit = 1
|
|
14
14
|
options.count = false
|
|
15
15
|
options.dataOnly = false
|
|
16
16
|
const { handler, schema, driver } = await resolveMethod.call(this, name, 'record-find', options)
|
|
17
|
+
if (!schema.cacheable) noCache = true
|
|
17
18
|
if (!noHook) {
|
|
18
19
|
await runHook(`${this.name}:beforeRecordFindOne`, name, filter, options)
|
|
19
20
|
await runHook(`${this.name}.${camelCase(name)}:beforeRecordFindOne`, filter, options)
|
|
@@ -8,11 +8,12 @@ async function find (name, filter = {}, opts = {}) {
|
|
|
8
8
|
const options = cloneDeep(omit(opts, ['req']))
|
|
9
9
|
options.req = opts.req
|
|
10
10
|
options.dataOnly = options.dataOnly ?? true
|
|
11
|
-
|
|
11
|
+
let { fields, dataOnly, noHook, noCache, hidden, forceNoHidden } = options
|
|
12
12
|
options.count = options.count ?? false
|
|
13
13
|
options.dataOnly = false
|
|
14
14
|
await this.modelExists(name, true)
|
|
15
15
|
const { handler, schema, driver } = await resolveMethod.call(this, name, 'record-find', options)
|
|
16
|
+
if (!schema.cacheable) noCache = true
|
|
16
17
|
filter.query = await this.buildQuery({ filter, schema, options }) ?? {}
|
|
17
18
|
if (options.queryHandler) filter.query = await options.queryHandler.call(opts.req ? this.app[opts.req.ns] : this, filter.query, opts.req)
|
|
18
19
|
filter.match = this.buildMatch({ input: filter.match, schema, options }) ?? {}
|
|
@@ -8,9 +8,10 @@ async function get (name, id, opts = {}) {
|
|
|
8
8
|
const options = cloneDeep(omit(opts, ['req']))
|
|
9
9
|
options.req = opts.req
|
|
10
10
|
options.dataOnly = options.dataOnly ?? true
|
|
11
|
-
|
|
11
|
+
let { fields, dataOnly, noHook, noCache, hidden = [], forceNoHidden } = options
|
|
12
12
|
await this.modelExists(name, true)
|
|
13
13
|
const { handler, schema, driver } = await resolveMethod.call(this, name, 'record-get', options)
|
|
14
|
+
if (!schema.cacheable) noCache = true
|
|
14
15
|
id = this.sanitizeId(id, schema)
|
|
15
16
|
options.dataOnly = false
|
|
16
17
|
if (!noHook) {
|
package/lib/sanitize-schema.js
CHANGED
|
@@ -44,6 +44,7 @@ async function sanitizeSchema (items) {
|
|
|
44
44
|
this.log.trace('- %s (%d)', k, keys(items[k]).length)
|
|
45
45
|
for (const f in items[k]) {
|
|
46
46
|
const item = items[k][f]
|
|
47
|
+
item.cacheable = item.cacheable ?? true
|
|
47
48
|
await runHook(`dobo.${camelCase(item.name)}:beforeSanitizeSchema`, item)
|
|
48
49
|
const conn = find(this.connections, { name: item.connection })
|
|
49
50
|
if (!conn) fatal.call(this, 'Unknown connection \'%s@%s\'', item.name, item.connection)
|