dobo 1.0.3 → 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
- const { fields, dataOnly, noHook, noCache, hidden, forceNoHidden } = options
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
- const { fields, dataOnly, noHook, noCache, hidden, forceNoHidden } = options
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
- const { fields, dataOnly, noHook, noCache, hidden = [], forceNoHidden } = options
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) {
@@ -41,6 +41,7 @@ async function addFixture (name, { spinner } = {}) {
41
41
  result.success++
42
42
  if (spinner) spinner.setText('%s: %d of %d records added', schema.name, result.success, items.length)
43
43
  } catch (err) {
44
+ console.log(err)
44
45
  err.model = schema.name
45
46
  if (this.app.bajo.applet) this.print.fail(this.validationErrorMessage(err))
46
47
  // else this.log.error('Add fixture \'%s@%s\' error: %s', schema.name, schema.connection, err.message)
@@ -32,9 +32,8 @@ async function handler ({ file, alias, ns }) {
32
32
  mod.feature = feats
33
33
  if ((mod.properties ?? []).length === 0) this.fatal('Schema \'%s\' doesn\'t have properties at all', mod.name)
34
34
  // schema extender
35
- const me = this
36
35
  await eachPlugins(async function (opts) {
37
- const glob = `${opts.dir}/${me.name}/extend/schema/${mod.name}.*`
36
+ const glob = `${opts.dir}/dobo/extend/schema/${mod.name}.*`
38
37
  const files = await fastGlob(glob)
39
38
  for (const file of files) {
40
39
  const extender = await readConfig(file, { ns: opts.ns, ignoreError: true })
@@ -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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dobo",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Database ORM/ODM for Bajo Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {