dobo 2.11.2 → 2.11.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/lib/collect-models.js
CHANGED
|
@@ -227,8 +227,8 @@ export async function sanitizeAll (model) {
|
|
|
227
227
|
async function createSchema (item) {
|
|
228
228
|
const { readConfig } = this.app.bajo
|
|
229
229
|
const { fastGlob } = this.app.lib
|
|
230
|
-
const { find, isPlainObject, orderBy } = this.app.lib._
|
|
231
|
-
const { mergeObjectsByKey } = this.app.lib.aneka
|
|
230
|
+
const { find, isPlainObject, orderBy, get, cloneDeep } = this.app.lib._
|
|
231
|
+
const { mergeObjectsByKey, defaultsDeep } = this.app.lib.aneka
|
|
232
232
|
if (item.file && !item.base) item.base = path.basename(item.file, path.extname(item.file))
|
|
233
233
|
item.attachment = item.attachment ?? true
|
|
234
234
|
const feats = item.features ?? []
|
|
@@ -245,8 +245,6 @@ async function createSchema (item) {
|
|
|
245
245
|
item.hooks = item.hooks ?? []
|
|
246
246
|
item.disabled = item.disabled ?? []
|
|
247
247
|
item.scanables = item.scanables ?? []
|
|
248
|
-
item.cache = item.cache ?? this.config.default.cache
|
|
249
|
-
if (item.cache === true) item.cache = this.config.default.cache
|
|
250
248
|
if (item.disabled === 'all') item.disabled = ['find', 'get', 'create', 'update', 'remove']
|
|
251
249
|
else if (item.disabled === 'readonly') item.disabled = ['create', 'update', 'remove']
|
|
252
250
|
// Is there any overwritten connection?
|
|
@@ -257,6 +255,11 @@ async function createSchema (item) {
|
|
|
257
255
|
if (!item.connection && conn === 'default') item.connection = this.getConnection('memory')
|
|
258
256
|
}
|
|
259
257
|
if (!item.connection) this.fatal('unknownConn%s%s', conn, item.name)
|
|
258
|
+
const defCache = cloneDeep(get(this, 'app.bajoCache.config.default', this.config.default.cache))
|
|
259
|
+
item.cache = item.cache ?? item.connection.options.cache ?? defCache
|
|
260
|
+
if (item.cache === true) item.cache = get(item, 'connection.options.cache', defCache)
|
|
261
|
+
else if (item.cache === false) item.cache = { ttlDur: 0 }
|
|
262
|
+
item.cache = defaultsDeep(get(this, `app.bajoCache.config.dobo.${item.name}`), item.cache)
|
|
260
263
|
await findAllProps.call(this, item, props, indexes)
|
|
261
264
|
await findAllFeats.call(this, item, feats, indexes)
|
|
262
265
|
await findAllIndexes.call(this, item, indexes)
|
|
@@ -6,7 +6,7 @@ async function native (...args) {
|
|
|
6
6
|
const { cloneDeep } = this.app.lib._
|
|
7
7
|
const [params = {}, opts = {}] = args
|
|
8
8
|
const { dataOnly = true } = opts
|
|
9
|
-
const { get: getCache, set: setCache } = this.app.bajoCache
|
|
9
|
+
const { get: getCache, set: setCache } = this.app.bajoCache ?? {}
|
|
10
10
|
const { filter, options } = await getFilterAndOptions.call(this, params, opts, action)
|
|
11
11
|
if (dataOnly) options.count = false
|
|
12
12
|
let { noResultSanitizer, noCache } = options
|
|
@@ -70,7 +70,7 @@ async function findRecord (...args) {
|
|
|
70
70
|
const { isSet } = this.app.lib.aneka
|
|
71
71
|
const { cloneDeep } = this.app.lib._
|
|
72
72
|
const { dataOnly = true } = opts
|
|
73
|
-
const { get: getCache, set: setCache } = this.app.bajoCache
|
|
73
|
+
const { get: getCache, set: setCache } = this.app.bajoCache ?? {}
|
|
74
74
|
const { filter, options } = await getFilterAndOptions.call(this, params, opts, action)
|
|
75
75
|
if (dataOnly) options.count = false
|
|
76
76
|
let { noResultSanitizer, noCache } = options
|
|
@@ -47,7 +47,7 @@ async function getRecord (...args) {
|
|
|
47
47
|
let [id, opts = {}] = args
|
|
48
48
|
const { isEmpty } = this.app.lib._
|
|
49
49
|
const { isSet } = this.app.lib.aneka
|
|
50
|
-
const { get: getCache, set: setCache } = this.app.bajoCache
|
|
50
|
+
const { get: getCache, set: setCache } = this.app.bajoCache ?? {}
|
|
51
51
|
const { dataOnly = true } = opts
|
|
52
52
|
const { options } = await getFilterAndOptions.call(this, null, opts, action)
|
|
53
53
|
let { noResultSanitizer, noCache } = options
|
package/package.json
CHANGED