dobo 2.0.0 → 2.0.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.
Files changed (139) hide show
  1. package/.github/FUNDING.yml +13 -0
  2. package/.github/workflows/repo-lockdown.yml +24 -0
  3. package/.jsdoc.conf.json +45 -0
  4. package/LICENSE +1 -1
  5. package/README.md +38 -19
  6. package/docs/Dobo.html +26 -0
  7. package/docs/data/search.json +1 -0
  8. package/docs/fonts/Inconsolata-Regular.ttf +0 -0
  9. package/docs/fonts/OpenSans-Regular.ttf +0 -0
  10. package/docs/fonts/WorkSans-Bold.ttf +0 -0
  11. package/docs/global.html +7 -0
  12. package/docs/index.html +3 -0
  13. package/docs/index.js.html +578 -0
  14. package/docs/lib_collect-connections.js.html +39 -0
  15. package/docs/lib_collect-drivers.js.html +52 -0
  16. package/docs/lib_collect-features.js.html +36 -0
  17. package/docs/lib_collect-schemas.js.html +94 -0
  18. package/docs/lib_index.js.html +6 -0
  19. package/docs/method_model_create.js.html +35 -0
  20. package/docs/method_model_drop.js.html +34 -0
  21. package/docs/method_model_exists.js.html +40 -0
  22. package/docs/method_record_count.js.html +69 -0
  23. package/docs/method_record_create.js.html +114 -0
  24. package/docs/method_record_find-all.js.html +44 -0
  25. package/docs/method_record_find-one.js.html +73 -0
  26. package/docs/method_record_find.js.html +118 -0
  27. package/docs/method_record_get.js.html +92 -0
  28. package/docs/method_record_remove.js.html +75 -0
  29. package/docs/method_record_update.js.html +107 -0
  30. package/docs/method_record_upsert.js.html +54 -0
  31. package/docs/method_sanitize_body.js.html +88 -0
  32. package/docs/method_sanitize_date.js.html +30 -0
  33. package/docs/method_sanitize_id.js.html +20 -0
  34. package/docs/method_validate.js.html +249 -0
  35. package/docs/module-Lib.html +3 -0
  36. package/docs/scripts/core.js +726 -0
  37. package/docs/scripts/core.min.js +23 -0
  38. package/docs/scripts/resize.js +90 -0
  39. package/docs/scripts/search.js +265 -0
  40. package/docs/scripts/search.min.js +6 -0
  41. package/docs/scripts/third-party/Apache-License-2.0.txt +202 -0
  42. package/docs/scripts/third-party/fuse.js +9 -0
  43. package/docs/scripts/third-party/hljs-line-num-original.js +369 -0
  44. package/docs/scripts/third-party/hljs-line-num.js +1 -0
  45. package/docs/scripts/third-party/hljs-original.js +5171 -0
  46. package/docs/scripts/third-party/hljs.js +1 -0
  47. package/docs/scripts/third-party/popper.js +5 -0
  48. package/docs/scripts/third-party/tippy.js +1 -0
  49. package/docs/scripts/third-party/tocbot.js +672 -0
  50. package/docs/scripts/third-party/tocbot.min.js +1 -0
  51. package/docs/static/bitcoin.jpeg +0 -0
  52. package/docs/static/home.md +25 -0
  53. package/docs/static/logo-ecosystem.png +0 -0
  54. package/docs/static/logo.png +0 -0
  55. package/docs/styles/clean-jsdoc-theme-base.css +1159 -0
  56. package/docs/styles/clean-jsdoc-theme-dark.css +412 -0
  57. package/docs/styles/clean-jsdoc-theme-light.css +482 -0
  58. package/docs/styles/clean-jsdoc-theme-scrollbar.css +30 -0
  59. package/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
  60. package/docs/styles/clean-jsdoc-theme.min.css +1 -0
  61. package/extend/bajo/intl/en-US.json +3 -2
  62. package/extend/bajo/intl/id.json +3 -2
  63. package/extend/bajoCli/applet/connection.js +5 -5
  64. package/extend/bajoCli/applet/lib/post-process.js +22 -16
  65. package/extend/bajoCli/applet/model-clear.js +4 -4
  66. package/extend/bajoCli/applet/model-rebuild.js +13 -13
  67. package/extend/bajoCli/applet/record-create.js +10 -8
  68. package/extend/bajoCli/applet/record-find.js +6 -5
  69. package/extend/bajoCli/applet/record-get.js +5 -5
  70. package/extend/bajoCli/applet/record-remove.js +5 -5
  71. package/extend/bajoCli/applet/record-update.js +9 -9
  72. package/extend/bajoCli/applet/schema.js +4 -4
  73. package/extend/bajoCli/applet/stat-count.js +4 -4
  74. package/extend/dobo/feature/created-at.js +1 -1
  75. package/extend/dobo/feature/removed-at.js +3 -3
  76. package/extend/dobo/feature/updated-at.js +2 -2
  77. package/extend/waibuMpa/route/attachment/@model/@id/@field/@file.js +3 -3
  78. package/index.js +230 -72
  79. package/lib/add-fixtures.js +5 -5
  80. package/lib/build-bulk-action.js +2 -2
  81. package/lib/check-unique.js +2 -2
  82. package/lib/collect-connections.js +14 -3
  83. package/lib/collect-drivers.js +14 -6
  84. package/lib/{collect-feature.js → collect-features.js} +12 -4
  85. package/lib/collect-schemas.js +17 -9
  86. package/lib/exec-feature-hook.js +1 -1
  87. package/lib/exec-validation.js +5 -5
  88. package/lib/generic-prop-sanitizer.js +6 -5
  89. package/lib/handle-attachment-upload.js +2 -2
  90. package/lib/index.js +3 -0
  91. package/lib/mem-db/conn-sanitizer.js +1 -1
  92. package/lib/mem-db/instantiate.js +4 -4
  93. package/lib/mem-db/method/record/find.js +1 -1
  94. package/lib/mem-db/method/record/get.js +1 -1
  95. package/lib/mem-db/method/record/remove.js +1 -1
  96. package/lib/mem-db/method/record/update.js +1 -1
  97. package/lib/mem-db/start.js +1 -1
  98. package/lib/merge-attachment-info.js +2 -2
  99. package/lib/multi-rel-rows.js +2 -2
  100. package/lib/resolve-method.js +3 -3
  101. package/lib/sanitize-schema.js +8 -7
  102. package/lib/single-rel-rows.js +2 -2
  103. package/method/attachment/copy-uploaded.js +2 -2
  104. package/method/attachment/create.js +3 -3
  105. package/method/attachment/find.js +2 -2
  106. package/method/attachment/get-path.js +3 -3
  107. package/method/attachment/get.js +1 -1
  108. package/method/attachment/pre-check.js +1 -1
  109. package/method/attachment/remove.js +1 -1
  110. package/method/bulk/create.js +6 -6
  111. package/method/model/clear.js +5 -5
  112. package/method/model/create.js +18 -5
  113. package/method/model/drop.js +17 -5
  114. package/method/model/exists.js +18 -5
  115. package/method/record/clear.js +5 -5
  116. package/method/record/count.js +27 -5
  117. package/method/record/create.js +46 -6
  118. package/method/record/find-all.js +16 -0
  119. package/method/record/find-one.js +20 -6
  120. package/method/record/find.js +69 -6
  121. package/method/record/get.js +48 -6
  122. package/method/record/remove.js +36 -5
  123. package/method/record/update.js +47 -6
  124. package/method/record/upsert.js +18 -2
  125. package/method/sanitize/body.js +18 -3
  126. package/method/sanitize/date.js +20 -7
  127. package/method/sanitize/id.js +10 -0
  128. package/method/stat/aggregate.js +4 -4
  129. package/method/stat/histogram.js +4 -4
  130. package/method/validate.js +96 -7
  131. package/package.json +41 -36
  132. package/wiki/APPLETS.md +57 -0
  133. package/wiki/CONFIG.md +25 -0
  134. package/wiki/CONTRIBUTING.md +5 -0
  135. package/wiki/DEV-GUIDE.md +1 -0
  136. package/wiki/ECOSYSTEM.md +20 -0
  137. package/wiki/GETTING-STARTED.md +166 -0
  138. package/wiki/USER-GUIDE.md +1 -0
  139. /package/{docs/query-language.md → wiki/QUERY-LANGUAGE.md} +0 -0
@@ -3,6 +3,80 @@ import joi from 'joi'
3
3
  const excludedTypes = ['object', 'array']
4
4
  const excludedNames = []
5
5
 
6
+ /**
7
+ * @typedef {string[]} TValidatorString
8
+ * @property {string} 0=alphanum
9
+ * @property {string} 1=base64
10
+ * @property {string} 2=case
11
+ * @property {string} 3=creditCard
12
+ * @property {string} 4=dataUri
13
+ * @property {string} 5=email
14
+ * @property {string} 6=guid
15
+ * @property {string} 7=uuid
16
+ * @property {string} 8=hex
17
+ * @property {string} 9=hostname
18
+ * @property {string} 10=insenstive
19
+ * @property {string} 11=ip
20
+ * @property {string} 12=isoDate
21
+ * @property {string} 13=isoDuration
22
+ * @property {string} 14=length
23
+ * @property {string} 15=lowercase
24
+ * @property {string} 16=max
25
+ * @property {string} 17=min
26
+ * @property {string} 18=normalize
27
+ * @property {string} 19=pattern
28
+ * @property {string} 20=regex
29
+ * @property {string} 21=replace
30
+ * @property {string} 22=token
31
+ * @property {string} 23=trim
32
+ * @property {string} 24=truncate
33
+ * @property {string} 25=upercase
34
+ * @property {string} 26=uri
35
+ */
36
+
37
+ /**
38
+ * @typedef {string[]} TValidatorNumber
39
+ * @property {string} 0=great
40
+ * @property {string} 1=less
41
+ * @property {string} 2=max
42
+ * @property {string} 3=min
43
+ * @property {string} 4=multiple
44
+ * @property {string} 5=negative
45
+ * @property {string} 6=port
46
+ * @property {string} 7=positive
47
+ * @property {string} 8=sign
48
+ * @property {string} 9=unsafe
49
+ */
50
+
51
+ /**
52
+ * @typedef {string[]} TValidatorBoolean
53
+ * @property {string} 0=falsy
54
+ * @property {string} 1=sensitive
55
+ * @property {string} 2=truthy
56
+ */
57
+
58
+ /**
59
+ * @typedef {string[]} TValidatorDate
60
+ * @property {string} 0=greater
61
+ * @property {string} 1=iso
62
+ * @property {string} 2=less
63
+ * @property {string} 2=max
64
+ * @property {string} 2=min
65
+ */
66
+
67
+ /**
68
+ * @typedef {string[]} TValidatorTimestamp
69
+ * @property {string} 0=timestamp
70
+ */
71
+
72
+ /**
73
+ * @typedef {Object} TValidator
74
+ * @property {TValidatorString} string
75
+ * @property {TValidatorNumber} number
76
+ * @property {TValidatorBoolean} boolean
77
+ * @property {TValidatorDate} date
78
+ * @property {TValidatorTimestamp} timestamp
79
+ */
6
80
  const validator = {
7
81
  string: ['alphanum', 'base64', 'case', 'creditCard', 'dataUri', 'domain', 'email', 'guid',
8
82
  'uuid', 'hex', 'hostname', 'insensitive', 'ip', 'isoDate', 'isoDuration', 'length', 'lowercase',
@@ -20,9 +94,9 @@ function buildFromDbSchema (schema, { fields = [], rule = {}, extFields = [] } =
20
94
  const {
21
95
  isPlainObject, get, each, isEmpty, isString, forOwn, keys,
22
96
  find, isArray, has, cloneDeep, concat, without
23
- } = this.lib._
97
+ } = this.app.lib._
24
98
  const obj = {}
25
- const me = this
99
+ const { propType } = this.app.pluginClass.dobo
26
100
  const refs = []
27
101
 
28
102
  function getRuleKv (kvRule) {
@@ -44,7 +118,7 @@ function buildFromDbSchema (schema, { fields = [], rule = {}, extFields = [] } =
44
118
  const rules = get(rule, prop.name, prop.rules ?? [])
45
119
  if (!isArray(rules)) return rules
46
120
  each(rules, r => {
47
- const types = validator[me.propType[prop.type].validator]
121
+ const types = validator[propType[prop.type].validator]
48
122
  const { key, value } = getRuleKv(r)
49
123
  if (keys(minMax).includes(key)) minMax[key] = true
50
124
  if (key === 'ref') {
@@ -110,7 +184,7 @@ function buildFromDbSchema (schema, { fields = [], rule = {}, extFields = [] } =
110
184
  each(without(keys(obj), ...refs), k => {
111
185
  const prop = find(props, { name: k })
112
186
  if (!prop) return undefined
113
- const types = validator[me.propType[prop.type].validator]
187
+ const types = validator[propType[prop.type].validator]
114
188
  const { key, value, columns = [] } = getRuleKv(r)
115
189
  if (!types.includes(key)) return undefined
116
190
  if (columns.length === 0 || columns.includes(k)) obj[k] = obj[k][key](value)
@@ -125,11 +199,26 @@ function buildFromDbSchema (schema, { fields = [], rule = {}, extFields = [] } =
125
199
  return result
126
200
  }
127
201
 
202
+ /**
203
+ * Validate value against JOI schema
204
+ *
205
+ * @method
206
+ * @memberof Dobo
207
+ * @async
208
+ * @param {Object} value - value to validate
209
+ * @param {Object} joiSchema - JOI schema
210
+ * @param {Object} [options={}] - Options object
211
+ * @param {string} [options.ns=dobo] - Scope's namespace
212
+ * @param {Array} [options.fields=[]]
213
+ * @param {Array} [options.extFields=[]]
214
+ * @param {Object} [options.params={}] - Validation parameters. See {@tutorial config} and {@link https://joi.dev/api/?v=17.13.3#anyvalidateasyncvalue-options|JOI validate's options}
215
+ * @returns {Object}
216
+ */
128
217
  async function validate (value, joiSchema, { ns, fields, extFields, params } = {}) {
129
- const { defaultsDeep, isSet } = this.lib.aneka
130
- const { isString, forOwn, find } = this.lib._
218
+ const { defaultsDeep, isSet } = this.app.lib.aneka
219
+ const { isString, forOwn, find } = this.app.lib._
131
220
 
132
- ns = ns ?? [this.name]
221
+ ns = ns ?? [this.ns]
133
222
  params = defaultsDeep(params, this.config.validationParams)
134
223
  const { rule = {} } = params
135
224
  delete params.rule
package/package.json CHANGED
@@ -1,36 +1,41 @@
1
- {
2
- "name": "dobo",
3
- "version": "2.0.0",
4
- "description": "Database ORM/ODM for Bajo Framework",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "type": "module",
10
- "bajo": {
11
- "type": "plugin"
12
- },
13
- "repository": {
14
- "type": "git",
15
- "url": "git+https://github.com/ardhi/dobo.git"
16
- },
17
- "keywords": [
18
- "database",
19
- "dobo",
20
- "db",
21
- "orm",
22
- "bajo",
23
- "framework"
24
- ],
25
- "author": "Ardhi Lukianto <ardhi@lukianto.com>",
26
- "license": "MIT",
27
- "bugs": {
28
- "url": "https://github.com/ardhi/dobo/issues"
29
- },
30
- "homepage": "https://github.com/ardhi/dobo#readme",
31
- "dependencies": {
32
- "@tryghost/nql": "^0.12.7",
33
- "joi": "^17.13.3",
34
- "mingo": "^6.5.1"
35
- }
36
- }
1
+ {
2
+ "name": "dobo",
3
+ "version": "2.0.1",
4
+ "description": "DBMS for Bajo Framework",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "build-doc": "jsdoc -c .jsdoc.conf.json",
8
+ "test": "mocha"
9
+ },
10
+ "type": "module",
11
+ "bajo": {
12
+ "type": "plugin"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/ardhi/dobo.git"
17
+ },
18
+ "keywords": [
19
+ "database",
20
+ "dobo",
21
+ "db",
22
+ "orm",
23
+ "bajo",
24
+ "framework"
25
+ ],
26
+ "author": "Ardhi Lukianto <ardhi@lukianto.com>",
27
+ "license": "MIT",
28
+ "bugs": {
29
+ "url": "https://github.com/ardhi/dobo/issues"
30
+ },
31
+ "homepage": "https://github.com/ardhi/dobo#readme",
32
+ "dependencies": {
33
+ "@tryghost/nql": "^0.12.7",
34
+ "joi": "^17.13.3",
35
+ "mingo": "^6.5.1"
36
+ },
37
+ "devDependencies": {
38
+ "clean-jsdoc-theme": "^4.3.0",
39
+ "jsdoc-plugin-intersection": "^1.0.4"
40
+ }
41
+ }
@@ -0,0 +1,57 @@
1
+ # Applet
2
+
3
+ ## connection
4
+
5
+ Gunakan applet ini untuk menampilkan koneksi database yang Anda miliki
6
+
7
+ ```bash
8
+ $ node index.js -a dobo:connection # Masuk ke mode interaktif
9
+ $ node index.js -a dobo:connection default # Tampilkan koneksi dengan nama 'default'
10
+ $ node index.js -a dobo:connection default --format=json # Tampilkan dalam format 'json'
11
+ ```
12
+
13
+ ## modelClear
14
+
15
+ Hapus tabel yang Anda inginkan. **Perhatian**: tabel akan dihapus dari database BESERTA isinya. Jadi pastikan bahwa Anda telah membackup tabel Anda terlebih dahulu sebelum Anda memanggil applet ini.
16
+
17
+ ```bash
18
+ $ node index.js -a dobo:modelRebuild # Masuk ke mode interaktif
19
+ $ node index.js -a dobo:modelRebuild 'Cdb*' # Hapus model dengan awalan 'Cdb'
20
+ ```
21
+
22
+ ## modelRebuild
23
+
24
+ Pada saat pertama kali sebuah plugin dimuat dan plugin meng-extend Dobo, Anda perlu memanggil applet ini untuk membuat tabel sesuai dengan skema yang telah ditentukan.
25
+
26
+ ```bash
27
+ $ node index.js -a dobo:modelRebuild # Gunakan mode interaktif
28
+ $ node index.js -a dobo:modelRebuild CdbCountry Sumba # Masukkan satu persatu nama modelnya
29
+ $ node index.js -a dobo:modelRebuild 'Cdb*' # List semua model dengan awalan 'Cdb'
30
+ ```
31
+ Setelah tabel sukses dibuat, maka jika model dilengkapi dengan fixture, fixture tersebut akan dimuat didalam tabel yang bersangkutan.
32
+
33
+ Jika tabel telah ada di database, Anda harus menggunakan switch ```--force``` untuk memaksa model bisa di hapus kemudian dibuat ulang kembali.
34
+
35
+ ## recordCreate
36
+
37
+ Gunakan applet ini untuk membuat rekord:
38
+
39
+ ```bash
40
+ $ node index.js -a dobo:recordCreate CdbCountry
41
+ ℹ App is running as applet...
42
+ ✔ Enter JSON payload: { "id": "XX", "name": "My Country" }
43
+ ╭ CdbCountry ─────────────╮
44
+ │ { │
45
+ │ "id": "XX", │
46
+ │ "name": "My Country" │
47
+ │ } │
48
+ ╰─────────────────────────╯
49
+ ? Are you sure to continue? (y/N)
50
+ ```
51
+
52
+ ## recordFind
53
+
54
+ Mencari rekord yang sesuai dengan kriteria pemilihan Anda. Jika kriteria tidak dimasukkan (filter kosong), maka akan diberikan semua rekord yang ada.
55
+
56
+ ```bash
57
+
package/wiki/CONFIG.md ADDED
@@ -0,0 +1,25 @@
1
+ # Config Object
2
+
3
+ | Key Name | Type | Default | Description |
4
+ | ------- | ---- | ----- | ----------- |
5
+ | ```connections``` | ```array``` | ```[]``` | Connection object |
6
+ | ```validationParams``` | ```object``` | | Defaults to [Joi validate's](https://joi.dev/api/?v=17.13.3#anyvalidateasyncvalue-options) options |
7
+ | &nbsp;&nbsp;&nbsp;&nbsp;```abortEarly``` | ```boolean``` | ```false``` | |
8
+ | &nbsp;&nbsp;&nbsp;&nbsp;```convert``` | ```boolean``` | ```false``` | |
9
+ | &nbsp;&nbsp;&nbsp;&nbsp;```allowUnknown``` | ```boolean``` | ```true``` | |
10
+ | ```default``` | ```object``` | | default values |
11
+ | &nbsp;&nbsp;&nbsp;&nbsp;```property``` | ```object``` | | |
12
+ | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;```text``` | ```object``` | | |
13
+ | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;```textType``` | ```string``` | ```text``` | Allowed values: ```text```, ```mediumtext```, or ```longtext``` |
14
+ | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;```string``` | ```object``` | | |
15
+ | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;```length``` | ```number``` | ```50``` | |
16
+ | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;```filter``` | ```object``` | | |
17
+ | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;```limit``` | ```number``` | ```25``` | Rows returned in one page |
18
+ | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;```maxLimit``` | ```number``` | ```200``` | Max rows returned in one page |
19
+ | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;```hardLimit``` | ```number``` | ```10000``` | Max rows returned on dataset export |
20
+ | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;```sort``` | ```array``` | | |
21
+ | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;```idField``` | ```object``` | | |
22
+ | ```memDb``` | ```object``` | | |
23
+ | &nbsp;&nbsp;&nbsp;&nbsp;```createDefConnAtStart``` | ```boolean``` | ```true``` | |
24
+ | &nbsp;&nbsp;&nbsp;&nbsp;```persistence``` | ```object``` | | |
25
+ | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;```syncPeriodDur``` | ```string | number``` | ```1s``` | |
@@ -0,0 +1,5 @@
1
+ # Contributing
2
+
3
+ Thanks very much to everyone who wants to join as a contributor, but I have committed to devoting 100% of my time to this project. Therefore, I'm currently unable to accept pull requests from anyone until the project is large enough for me to manage it independently.
4
+
5
+ However, I am available if you encounter any bugs that require immediate fixes. Please report your issues in a GitHub issue, and I'll try to address them promptly. I'm also open to criticism and suggestions for improvements or requests for new features.
@@ -0,0 +1 @@
1
+ # Developer Guide
@@ -0,0 +1,20 @@
1
+ # Ecosystem
2
+
3
+ ## Drivers
4
+
5
+ | Package | Docs | NS | Alias | Description |
6
+ | ------- | ---- | -- | ----- | ----------- |
7
+ | [dobo-couchdb](https://github.com/ardhi/dobo-couchdb) | [Docs](https://ardhi.github.io/dobo-couchdb) | doboCouchdb | dbcouch | CouchDB Driver |
8
+ | [dobo-elasticsearch](https://github.com/ardhi/dobo-elasticsearch) | [Docs](https://ardhi.github.io/dobo-elasticsearch) | doboElasticsearch | dbes | Elasticsearch Driver |
9
+ | [dobo-knex](https://github.com/ardhi/dobo-knex) | [Docs](https://ardhi.github.io/dobo-knex) | doboKnex | dbknex | Knex/SQL Driver |
10
+ | [dobo-mongodb](https://github.com/ardhi/dobo-mongodb) | [Docs](https://ardhi.github.io/dobo-mongodb) | doboMongodb | dbmongo | MongoDB Driver |
11
+ | [dobo-redis](https://github.com/ardhi/dobo-redis) | [Docs](https://ardhi.github.io/dobo-redis) | doboRedis | dbredis | Redis Driver |
12
+ | [dobo-restproxy](https://github.com/ardhi/dobo-restproxy) | [Docs](https://ardhi.github.io/dobo-restproxy) | doboRestproxy | dbrpx | Restproxy Driver |
13
+ | [dobo-restproxy-jsonserver](https://github.com/ardhi/dobo-restproxy-jsonserver) | [Docs](https://ardhi.github.io/dobo-restproxy-jsonserver) | doboResporoxyJsonserver | dbrpxjs |JsonServer Support for doboRestproxy |
14
+ | [dobo-restproxy-ndut](https://github.com/ardhi/dobo-restproxy-ndut) | [Docs](https://ardhi.github.io/dobo-restproxy-ndut) | doboRestproxyNdut | dbrpxndut | NDUT Support for doboRestproxy |
15
+
16
+ ## Misc
17
+
18
+ | Package | Docs | NS | Alias | Description |
19
+ | ------- | ---- | -- | ----- | ----------- |
20
+ | [dobo-extra](https://github.com/ardhi/dobo-extra) | [Docs](https://ardhi.github.io/dobo-extra) | doboExtra | dbx | Dobo Extra Tools/Utility |
@@ -0,0 +1,166 @@
1
+ # Getting Started
2
+
3
+ > If you're new to the [Dobo DBMS](https://ardhi.github.io/dobo), we recommend you to read and follow along with [Bajo Tutorial](https://ardhi.github.io/bajo/tutorial-01-getting-started.html) first, as this document is the continuation of it
4
+
5
+ **Dobo** is the Bajo sub-framework developed specifically to handle database management. In this tutorial, we'll go over how to install the necessary packages and interact with them.
6
+
7
+ Here is some basic knowledge about Dobo you need to be familiar with:
8
+
9
+ - All record-related actions mimic REST API methods: *find* records, *get* a particular record by its ID, *create* a new record, *update* an existing record by ID and payload, and *remove* an existing record by its ID.
10
+ - A Dobo model requires a predefined schema. Even if you use a NoSQL database, you still need to write a schema.
11
+ - There are two main groups of methods to be familiar with:
12
+ - ```dobo.model{Action}``` methods manage everything related to model management, such as table creation or deletion.
13
+ - ```dobo.record{Action}``` methods handle record manipulation.
14
+ - A record in Bajo always needs to have an ID. The ID can be alphanumeric characters or an integer, and it is defined by the underlying driver used by the model.
15
+
16
+ For more info about Dobo, please [click here](https://ardhi.github.io/dobo).
17
+
18
+ ### Installation
19
+
20
+ As you might have guessed, Dobo and its drivers are normal Bajo plugins. Although [many drivers](https://github.com/ardhi/dobo/tutorials/drivers.md) exist, for this tutorial, we'll only use SQLite 3, which is provided by the dobo-knex driver.
21
+
22
+ Now, please install the required plugins and SQLite drivers first:
23
+
24
+ ```bash
25
+ $ npm install dobo dobo-knex sqlite3
26
+ ```
27
+
28
+ Don't forget to add ```dobo``` and ```dobo-knex``` to the ```data/config/.plugins``` file.
29
+
30
+ ### Model
31
+
32
+ Let's pretend we're building an address book with fields like name, age, phone, etc. This entity needs to be modeled with a schema and then "connected" to a database:
33
+
34
+ 1. Create ```main/extend/dobo/schema/address-book.json``` file.
35
+ 2. Enter the following schema:
36
+ ```json
37
+ {
38
+ "properties": [{
39
+ "name": "firstName",
40
+ "type": "string",
41
+ "maxLength": 20,
42
+ "required": true,
43
+ "index": true
44
+ },
45
+ "lastName::20:true:true",
46
+ "age:smallint",
47
+ "phone::20:true:true",
48
+ "email::50:true"
49
+ ],
50
+ "feature": {
51
+ "createdAt": true,
52
+ "updatedAt": true
53
+ }
54
+ }
55
+ ```
56
+ You should notice here that in properties you can use either the verbose, full-object syntax or the string-based one. Please visit the Dobo documentation to learn more.
57
+
58
+ 3. Create ```main/extend/dobo/fixture/address-book.json``` file. Fixtures allow you to quickly fill your database with predefined records. It's not required, but it helps a lot with prototyping.
59
+ ```json
60
+ [{
61
+ "firstName": "James",
62
+ "lastName": "Bond",
63
+ "phone": "+44-007"
64
+ }, {
65
+ "firstName": "Felix",
66
+ "lastName": "Leiter",
67
+ "age": 50,
68
+ "phone": "+1-0000001"
69
+ }]
70
+ ```
71
+ 4. By default, all schemas are connected to a database connection named ```default```. Now let's create this connection by creating ```data/config/dobo.json``` file:
72
+
73
+ ```json
74
+ {
75
+ "connections": [{
76
+ "name": "default",
77
+ "type": "knex:sqlite3",
78
+ "connection": {
79
+ "filename": "my-project.sqlite3"
80
+ }
81
+ }]
82
+ }
83
+ ```
84
+ 5. That's all there is to it. Now you need to build this model like this:
85
+ ```
86
+ $ node index.js -a dobo:modelRebuild MainAddressBook
87
+ ℹ App runs in applet mode
88
+ ╭ Schema (1) ──────╮
89
+ │ MainAddressBook │
90
+ ╰──────────────────╯
91
+ ✔ The above mentioned schema(s) will be rebuilt as model. Continue? Yes
92
+ ✔ Model 'MainAddressBook' successfully created
93
+ ℹ Done! Succeded: 1, failed: 0, skipped: 0
94
+ ✔ Fixture on 'MainAddressBook': added 2, rejected: 0
95
+ ```
96
+ 6. Done!
97
+
98
+ Note: Although you can use YAML or TOML for schemas/fixtures, it's recommended to stick with JSON because it's always supported and doesn't require an extra plugin.
99
+
100
+ Dobo models are by default always named with ```{Alias}{ModelName}```, which is a pascal-cased plugin alias and base name from your schema file. For field names, Dobo use camel-cased names as a convention. You can change this behavior to match your needs, but it is suggested that you're keeping these conventions at least for this tutorial.
101
+
102
+ ### Applets
103
+
104
+ Dobo provides you with a number of applets that will help you manipulate models and records directly. This means you don't have to touch your tables and databases directly through SQL statements or NoSQL procedures ever again. Everything can be managed through one common syntax provided by Dobo, regardless of your backend type.
105
+
106
+ First, let's try to list records:
107
+
108
+ ```bash
109
+ $ node index.js -a dobo:recordFind MainAddressBook
110
+ ℹ App runs in applet mode
111
+ ✔ Please enter your query (if any):
112
+ ✔ Done
113
+ ┌────┬───────────┬──────────┬─────┬────────────┬───────┬──────────────────────────┬──────────────────────────┐
114
+ │ id │ firstName │ lastName │ age │ phone │ email │ createdAt │ updatedAt │
115
+ ├────┼───────────┼──────────┼─────┼────────────┼───────┼──────────────────────────┼──────────────────────────┤
116
+ │ 2 │ Felix │ Leiter │ 50 │ +1-0000001 │ │ 2025-09-18T13:47:29.296Z │ 2025-09-18T13:47:29.296Z │
117
+ ├────┼───────────┼──────────┼─────┼────────────┼───────┼──────────────────────────┼──────────────────────────┤
118
+ │ 1 │ James │ Bond │ │ +44-007 │ │ 2025-09-18T13:47:29.280Z │ 2025-09-18T13:47:29.280Z │
119
+ └────┴───────────┴──────────┴─────┴────────────┴───────┴──────────────────────────┴──────────────────────────┘
120
+ ```
121
+
122
+ Now, add a new record:
123
+
124
+ ```bash
125
+ $ node index.js -a dobo:recordCreate MainAddressBook
126
+ ℹ App runs in applet mode
127
+ ✔ Enter JSON payload: { "firstName": "Miss", "lastName": "Moneypenny" }
128
+ ╭ MainAddressBook ────────────╮
129
+ │ { │
130
+ │ "firstName": "Miss", │
131
+ │ "lastName": "Moneypenny" │
132
+ │ } │
133
+ ╰─────────────────────────────╯
134
+ ✖ Error: Validation Error
135
+ ✔ Enter JSON payload: { "firstName": "Miss", "lastName": "Moneypenny", "phone": "+44-111" }
136
+ ╭ MainAddressBook ─────────────╮
137
+ │ { │
138
+ │ "firstName": "Miss", │
139
+ │ "lastName": "Moneypenny", │
140
+ │ "phone": "+44-111" │
141
+ │ } │
142
+ ╰──────────────────────────────╯
143
+ ✔ Done
144
+ ┌───────────┬──────────────────────────┐
145
+ │ id │ 3 │
146
+ ├───────────┼──────────────────────────┤
147
+ │ firstName │ Miss │
148
+ ├───────────┼──────────────────────────┤
149
+ │ lastName │ Moneypenny │
150
+ ├───────────┼──────────────────────────┤
151
+ │ age │ │
152
+ ├───────────┼──────────────────────────┤
153
+ │ phone │ +44-111 │
154
+ ├───────────┼──────────────────────────┤
155
+ │ email │ │
156
+ ├───────────┼──────────────────────────┤
157
+ │ createdAt │ 2025-09-18T14:38:11.933Z │
158
+ ├───────────┼──────────────────────────┤
159
+ │ updatedAt │ 2025-09-18T14:38:11.933Z │
160
+ └───────────┴──────────────────────────┘
161
+ ```
162
+
163
+ As you can see, Dobo is smart enough to reject any payload that isn't right. In this case, we forgot to include the phone number since according to the schema, this field is defined as required.
164
+
165
+ You can now try all of Dobo's other applets. [This page](https://github.com/ardhi/dobo/tutorials/applets) provides its complete list.
166
+
@@ -0,0 +1 @@
1
+ # User Guide