dobo 2.3.0 → 2.3.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.
@@ -126,7 +126,7 @@ async function findAllIndexes (model, inputs = []) {
126
126
  * @param {Object} model - Model
127
127
  * @param {Array} [models] - All model match agaist. Defaults to ```dobo.models```
128
128
  */
129
- export async function sanitizeRef (model, models, fatal) {
129
+ export async function sanitizeRef (model, models) {
130
130
  const { find, isString, pullAt } = this.app.lib._
131
131
  if (!models) models = this.models
132
132
  for (const prop of model.properties) {
@@ -139,13 +139,15 @@ export async function sanitizeRef (model, models, fatal) {
139
139
  ref.type = ref.type ?? '1:1'
140
140
  const rModel = find(models, { name: ref.model })
141
141
  if (!rModel) {
142
- if (fatal) this.fatal('unknownModelForRef%s%s%s', ref.model, model.name, prop.name)
143
- else ignored.push(ref.model)
142
+ ignored.push(key)
143
+ this.log.warn('notFound%s%s', this.t('model'), ref.model)
144
+ continue
144
145
  }
145
146
  const rProp = find(rModel.properties, { name: ref.propName })
146
147
  if (!rProp) {
147
- if (fatal) this.fatal('unknownPropForRef%s%s%s%s', ref.model, ref.propName, model.name, prop.name)
148
- else ignored.push(ref.model)
148
+ ignored.push(key)
149
+ this.log.warn('notFound%s%s', this.t('property'), `${ref.propName}@${ref.model}`)
150
+ continue
149
151
  }
150
152
  ref.fields = ref.fields ?? '*'
151
153
  if (['*', 'all'].includes(ref.fields)) ref.fields = rModel.properties.map(p => p.name)
@@ -189,7 +189,7 @@ export async function getSingleRef (record = {}, options = {}) {
189
189
 
190
190
  export async function getMultiRefs (records = [], options = {}) {
191
191
  const { isSet } = this.app.lib.aneka
192
- const { uniq, map, get } = this.app.lib._
192
+ const { uniq, without, get } = this.app.lib._
193
193
  const props = this.properties.filter(p => isSet(p.ref) && !(options.hidden ?? []).includes(p.name))
194
194
  options.refs = options.refs ?? []
195
195
  if (props.length > 0) {
@@ -201,15 +201,16 @@ export async function getMultiRefs (records = [], options = {}) {
201
201
  if (ref.type !== '1:1') continue
202
202
  if (get(records, `0._ref.${key}`)) continue
203
203
  const rModel = this.app.dobo.getModel(ref.model)
204
- const matches = uniq(map(records, r => {
205
- let v = r[prop.name]
206
- if (ref.propName === 'id') v = this.sanitizeId(v)
207
- return v
208
- }))
204
+ let matches = []
205
+ for (const r of records) {
206
+ matches.push(rModel.sanitizeId(r[prop.name]))
207
+ }
208
+ matches = uniq(without(matches, undefined, null, NaN))
209
209
  const query = {}
210
210
  query[ref.propName] = { $in: matches }
211
211
  const rFilter = { query, limit: matches.length }
212
212
  const rOptions = { dataOnly: true, refs: [] }
213
+ this.app.dump(this.name, rModel.name, rFilter, records)
213
214
  const results = await rModel.findRecord(rFilter, rOptions)
214
215
  const fields = [...ref.fields]
215
216
  if (!fields.includes(prop.name)) fields.push(prop.name)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dobo",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "DBMS for Bajo Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-01-26
4
+
5
+ - [2.3.1] Bug fix if reference model isn't loaded only yield warning
6
+ - [2.3.1] Bug fix on fetching multi references
7
+
3
8
  ## 2026-01-24
4
9
 
5
10
  - [2.3.0] Add ```dynHooks``` to model's options