bajo-common-db 2.2.0 → 2.2.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 CHANGED
@@ -19,6 +19,17 @@ async function factory (pkgName) {
19
19
  title: 'Common Database'
20
20
  }
21
21
  }
22
+
23
+ getCountryByMmsi = (mmsi, returnRec = false) => {
24
+ if (!this.app.dobo) return
25
+ // this won't use Dobo's model interface, it scans directly on memdb storage instead
26
+ const head = parseInt(mmsi.slice(0, 3))
27
+ const instance = this.app.dobo.getModel('CdbCountry', true)
28
+ if (!instance) return
29
+ const country = instance.driver.storage.CdbCountry.find(item => (item.mmsi ?? []).includes(head))
30
+ if (returnRec) return country
31
+ return country ? country._id : undefined
32
+ }
22
33
  }
23
34
 
24
35
  return BajoCommonDb
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bajo-common-db",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "Common Database for Bajo Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-01-15
4
+
5
+ - [2.2.1] Add method ```getCountryByMmsi()```
6
+
3
7
  ## 2025-12-21
4
8
 
5
- - Rename field ```mids``` to ```mmsi``` in ```CdbCountry```
9
+ - [2.2.0] Rename field ```mids``` to ```mmsi``` in ```CdbCountry```
6
10
 
7
11
  ## 2025-12-10
8
12