dobo 2.30.7 → 2.32.0

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 (123) hide show
  1. package/.jsdoc.conf.json +1 -1
  2. package/docs/Dobo.html +1 -24
  3. package/docs/DoboAction.html +13 -0
  4. package/docs/DoboAdapter.html +3 -0
  5. package/docs/DoboConnection.html +3 -0
  6. package/docs/DoboFeature.html +3 -0
  7. package/docs/DoboModel.html +51 -0
  8. package/docs/data/search.json +1 -1
  9. package/docs/extend_bajo_hook-docs.js.html +241 -0
  10. package/docs/external-Tools.html +3 -0
  11. package/docs/global.html +1 -5
  12. package/docs/index.html +1 -1
  13. package/docs/index.js.html +434 -380
  14. package/docs/lib_factory_action.js.html +290 -0
  15. package/docs/lib_factory_adapter.js.html +1057 -0
  16. package/docs/lib_factory_connection.js.html +112 -0
  17. package/docs/lib_factory_feature.js.html +55 -0
  18. package/docs/lib_factory_model.js.html +503 -0
  19. package/docs/lib_factory_model_build.js.html +28 -0
  20. package/docs/lib_factory_model_clear-record.js.html +33 -0
  21. package/docs/lib_factory_model_count-record.js.html +45 -0
  22. package/docs/lib_factory_model_create-record.js.html +52 -0
  23. package/docs/lib_factory_model_drop.js.html +29 -0
  24. package/docs/lib_factory_model_exists.js.html +29 -0
  25. package/docs/lib_factory_model_find-all-record.js.html +115 -0
  26. package/docs/lib_factory_model_find-one-record.js.html +41 -0
  27. package/docs/lib_factory_model_find-record.js.html +85 -0
  28. package/docs/lib_factory_model_get-record.js.html +55 -0
  29. package/docs/lib_factory_model_helper.js.html +579 -0
  30. package/docs/lib_factory_model_remove-record.js.html +47 -0
  31. package/docs/lib_factory_model_sanitize-body.js.html +60 -0
  32. package/docs/lib_factory_model_sanitize-fixture.js.html +59 -0
  33. package/docs/lib_factory_model_sanitize-record.js.html +73 -0
  34. package/docs/lib_factory_model_update-record.js.html +61 -0
  35. package/docs/lib_factory_model_upsert-record.js.html +74 -0
  36. package/docs/{method_validate.js.html → lib_factory_model_validate.js.html} +109 -73
  37. package/docs/lib_helper.js.html +466 -0
  38. package/docs/module-Helper.html +3 -0
  39. package/docs/module-Helper_Model.html +3 -0
  40. package/docs/module-Hook.html +15 -0
  41. package/docs/scripts/core.js +477 -476
  42. package/docs/scripts/resize.js +36 -36
  43. package/docs/scripts/search.js +105 -105
  44. package/docs/scripts/third-party/fuse.js +1 -1
  45. package/docs/scripts/third-party/hljs-line-num-original.js +285 -282
  46. package/docs/scripts/third-party/hljs-line-num.js +1 -1
  47. package/docs/scripts/third-party/hljs-original.js +1202 -1195
  48. package/docs/scripts/third-party/hljs.js +1 -1
  49. package/docs/scripts/third-party/popper.js +1 -1
  50. package/docs/scripts/third-party/tippy.js +1 -1
  51. package/docs/scripts/third-party/tocbot.js +509 -508
  52. package/docs/static/home.md +3 -1
  53. package/extend/bajo/hook-docs.js +238 -0
  54. package/extend/bajo/intl/en-US.json +9 -9
  55. package/extend/bajo/intl/id.json +9 -9
  56. package/extend/bajoCli/applet/rebuild-model.js +2 -2
  57. package/extend/dobo/{driver → adapter}/memory.js +6 -6
  58. package/extend/dobo/feature/immutable.js +2 -2
  59. package/extend/dobo/feature/removed-at.js +1 -1
  60. package/index.js +33 -30
  61. package/lib/factory/action.js +145 -18
  62. package/lib/factory/adapter.js +1054 -0
  63. package/lib/factory/connection.js +46 -22
  64. package/lib/factory/feature.js +23 -3
  65. package/lib/factory/model/build.js +11 -2
  66. package/lib/factory/model/bulk-create-record.js +2 -2
  67. package/lib/factory/model/clear-record.js +13 -3
  68. package/lib/factory/model/count-record.js +13 -2
  69. package/lib/factory/model/create-aggregate.js +2 -2
  70. package/lib/factory/model/create-attachment.js +1 -1
  71. package/lib/factory/model/create-histogram.js +2 -2
  72. package/lib/factory/model/create-record.js +15 -2
  73. package/lib/factory/model/drop.js +12 -2
  74. package/lib/factory/model/exists.js +10 -6
  75. package/lib/factory/model/find-all-record.js +14 -3
  76. package/lib/factory/model/find-attachment.js +1 -1
  77. package/lib/factory/model/find-one-record.js +13 -1
  78. package/lib/factory/model/find-record.js +17 -53
  79. package/lib/factory/model/get-record.js +11 -39
  80. package/lib/factory/model/{_util.js → helper.js} +176 -16
  81. package/lib/factory/model/remove-attachment.js +1 -1
  82. package/lib/factory/model/remove-record.js +11 -28
  83. package/lib/factory/model/sanitize-body.js +14 -12
  84. package/lib/factory/model/sanitize-fixture.js +17 -4
  85. package/lib/factory/model/sanitize-record.js +9 -6
  86. package/lib/factory/model/transaction.js +2 -2
  87. package/lib/factory/model/update-record.js +12 -40
  88. package/lib/factory/model/upsert-record.js +13 -42
  89. package/lib/factory/model/validate.js +47 -14
  90. package/lib/factory/model.js +301 -23
  91. package/lib/{collect-models.js → helper.js} +463 -364
  92. package/package.json +1 -1
  93. package/wiki/CHANGES.md +17 -7
  94. package/wiki/ECOSYSTEM.md +7 -7
  95. package/wiki/GETTING-STARTED.md +3 -3
  96. package/wiki/QUERY-LANGUAGE.md +1 -1
  97. package/docs/lib_collect-connections.js.html +0 -39
  98. package/docs/lib_collect-drivers.js.html +0 -52
  99. package/docs/lib_collect-features.js.html +0 -36
  100. package/docs/lib_collect-schemas.js.html +0 -94
  101. package/docs/lib_index.js.html +0 -6
  102. package/docs/method_model_create.js.html +0 -35
  103. package/docs/method_model_drop.js.html +0 -34
  104. package/docs/method_model_exists.js.html +0 -40
  105. package/docs/method_record_count.js.html +0 -69
  106. package/docs/method_record_create.js.html +0 -114
  107. package/docs/method_record_find-all.js.html +0 -44
  108. package/docs/method_record_find-one.js.html +0 -73
  109. package/docs/method_record_find.js.html +0 -118
  110. package/docs/method_record_get.js.html +0 -92
  111. package/docs/method_record_remove.js.html +0 -75
  112. package/docs/method_record_update.js.html +0 -107
  113. package/docs/method_record_upsert.js.html +0 -54
  114. package/docs/method_sanitize_body.js.html +0 -88
  115. package/docs/method_sanitize_date.js.html +0 -30
  116. package/docs/method_sanitize_id.js.html +0 -20
  117. package/docs/module-Lib.html +0 -3
  118. package/lib/collect-connections.js +0 -56
  119. package/lib/collect-drivers.js +0 -35
  120. package/lib/collect-features.js +0 -40
  121. package/lib/factory/driver.js +0 -574
  122. package/lib/factory/model/sanitize-id.js +0 -7
  123. package/lib/index.js +0 -3
@@ -1,6 +1,8 @@
1
1
  ![Dobo DBMS](static/logo.png)
2
2
 
3
- ### Dobo Database Management System for [Bajo](https://github.com/ardhi/bajo)
3
+ ### Dobo DBMS Framework for [Bajo](https://github.com/ardhi/bajo)
4
+
5
+ The database management system (DBMS) for Bajo Framework. It provides a simple and easy-to-use interface for managing databases, tables, and records. It supports multiple database engines and can be easily extended to support new ones.
4
6
 
5
7
  ## Hire Me
6
8
 
@@ -0,0 +1,238 @@
1
+ /**
2
+ * Available hooks for Dobo's operations. You can use these hooks to customize the behavior of the model's CRUD operations.
3
+ *
4
+ * For any of the hooks below, you can also use the `modelName` in camelCase format to create a model-specific hook. If you
5
+ * choose to use this format, you must omit the first parameter (`model`) so that the hook function handler syntax will become like this:
6
+ *
7
+ * ```js
8
+ * dobo.{modelName}:beforeCreateRecord (body, options)
9
+ * dobo.{modelName}:afterCreateRecord (body, options)
10
+ * dobo.{modelName}:beforeFindRecord (filter, options)
11
+ * dobo.{modelName}:afterFindRecord (filter, result, options)
12
+ * ...
13
+ * ```
14
+ *
15
+ * You can use both formats simultaneously if you want. In that case, they will be executed in this order:
16
+ * ```js
17
+ * dobo:beforeCreateRecord (model, body, options)
18
+ * dobo.{modelName}:beforeCreateRecord (body, options)
19
+ * ...
20
+ * dobo.{modelName}:afterCreateRecord (body, result, options)
21
+ * dobo:afterCreateRecord (model, body, result, options)
22
+ * ```
23
+ *
24
+ * For both formats, there are their counterparts that run deep inside the adapter.
25
+ * Only use these hooks if you know what you are doing.
26
+ *
27
+ * Their syntax is similar to the above, with one exception: you need to put suffix `.adapter` after `dobo`:
28
+ *
29
+ * ```js
30
+ * dobo.adapter:beforeAdapterCreateRecord (model, body, options)
31
+ * dobo.adapter.{modelName}:beforeAdapterCreateRecord (body, options)
32
+ * ```
33
+ * @module Hook
34
+ */
35
+ /**
36
+ * Hook that is called before creating a record.
37
+ *
38
+ * @memberof module:Hook
39
+ * @method
40
+ * @async
41
+ * @name dobo:beforeCreateRecord
42
+ * @param {DoboModel} model - The model instance
43
+ * @param {object} body - The body payload to be created
44
+ * @param {DoboModel.TOptions} options - The options object
45
+ */
46
+
47
+ /**
48
+ * Hook that is called after creating a record.
49
+ *
50
+ * @memberof module:Hook
51
+ * @method
52
+ * @async
53
+ * @name dobo:afterCreateRecord
54
+ * @param {DoboModel} model - The model instance
55
+ * @param {object} body - The body payload to be created
56
+ * @param {DoboModel.TResultRecord} result - The result of the create operation
57
+ * @param {DoboModel.TOptions} options - The options object
58
+ */
59
+
60
+ /**
61
+ * Hook that is called before finding records.
62
+ *
63
+ * @memberof module:Hook
64
+ * @method
65
+ * @async
66
+ * @name dobo:beforeFindRecord
67
+ * @param {DoboModel} model - The model instance
68
+ * @param {DoboModel.TFilter} filter - The filter criteria to apply when finding records
69
+ * @param {DoboModel.TOptions} options - The options object
70
+ */
71
+
72
+ /**
73
+ * Hook that is called after finding records.
74
+ *
75
+ * @memberof module:Hook
76
+ * @method
77
+ * @async
78
+ * @name dobo:afterFindRecord
79
+ * @param {DoboModel} model - The model instance
80
+ * @param {DoboModel.TFilter} filter - The filter criteria applied when finding records
81
+ * @param {DoboModel.TResultFindRecord} result - The result of the find operation
82
+ * @param {DoboModel.TOptions} options - The options object
83
+ */
84
+
85
+ /**
86
+ * Hook that is called before finding one record.
87
+ *
88
+ * @memberof module:Hook
89
+ * @method
90
+ * @async
91
+ * @name dobo:beforeFindOneRecord
92
+ * @param {DoboModel} model - The model instance
93
+ * @param {DoboModel.TFilter} filter - The filter criteria to apply when finding one record
94
+ * @param {DoboModel.TResultFindRecord} result - The result of the find operation
95
+ * @param {DoboModel.TOptions} options - The options object
96
+ */
97
+
98
+ /**
99
+ * Hook that is called after finding one record.
100
+ *
101
+ * @memberof module:Hook
102
+ * @method
103
+ * @async
104
+ * @name dobo:afterFindOneRecord
105
+ * @param {DoboModel} model - The model instance
106
+ * @param {DoboModel.TFilter} filter - The filter criteria applied when finding one record
107
+ * @param {DoboModel.TResultFindOneRecord} result - The result of the find one operation
108
+ * @param {DoboModel.TOptions} options - The options object
109
+ */
110
+
111
+ /**
112
+ * Hook that is called before finding all records.
113
+ *
114
+ * @memberof module:Hook
115
+ * @method
116
+ * @async
117
+ * @name dobo:beforeFindAllRecord
118
+ * @param {DoboModel} model - The model instance
119
+ * @param {DoboModel.TFilter} filter - The filter criteria to apply when finding all records
120
+ * @param {DoboModel.TOptions} options - The options object
121
+ */
122
+
123
+ /**
124
+ * Hook that is called after finding all records.
125
+ *
126
+ * @memberof module:Hook
127
+ * @method
128
+ * @async
129
+ * @name dobo:afterFindAllRecord
130
+ * @param {DoboModel} model - The model instance
131
+ * @param {DoboModel.TFilter} filter - The filter criteria applied when finding all records
132
+ * @param {DoboModel.TResultFindAllRecord} result - The result of the find all operation
133
+ * @param {DoboModel.TOptions} options - The options object
134
+ */
135
+
136
+ /**
137
+ * Hook that is called before updating a record.
138
+ *
139
+ * @memberof module:Hook
140
+ * @method
141
+ * @async
142
+ * @name dobo:beforeUpdateRecord
143
+ * @param {DoboModel} model - The model instance
144
+ * @param {string|number} id - The ID of the record to be updated
145
+ * @param {object} body - The body payload to be updated
146
+ * @param {DoboModel.TOptions} options - The options object
147
+ */
148
+
149
+ /**
150
+ * Hook that is called after updating a record.
151
+ *
152
+ * @memberof module:Hook
153
+ * @method
154
+ * @async
155
+ * @name dobo:afterUpdateRecord
156
+ * @param {DoboModel} model - The model instance
157
+ * @param {string|number} id - The ID of the record that was updated
158
+ * @param {object} body - The body payload that was updated
159
+ * @param {DoboModel.TResultUpdateRecord} result - The result of the update operation
160
+ * @param {DoboModel.TOptions} options - The options object
161
+ */
162
+
163
+ /**
164
+ * Hook that is called before removing a record.
165
+ *
166
+ * @memberof module:Hook
167
+ * @method
168
+ * @async
169
+ * @name dobo:beforeRemoveRecord
170
+ * @param {DoboModel} model - The model instance
171
+ * @param {string|number} id - The ID of the record to be removed
172
+ * @param {DoboModel.TOptions} options - The options object
173
+ */
174
+
175
+ /**
176
+ * Hook that is called after removing a record.
177
+ *
178
+ * @memberof module:Hook
179
+ * @method
180
+ * @async
181
+ * @name dobo:afterRemoveRecord
182
+ * @param {DoboModel} model - The model instance
183
+ * @param {string|number} id - The ID of the record that was removed
184
+ * @param {DoboModel.TResultRemoveRecord} result - The result of the remove operation
185
+ * @param {DoboModel.TOptions} options - The options object
186
+ */
187
+
188
+ /**
189
+ * Hook that is called before counting records.
190
+ *
191
+ * @memberof module:Hook
192
+ * @method
193
+ * @async
194
+ * @name dobo:beforeCountRecord
195
+ * @param {DoboModel} model - The model instance
196
+ * @param {DoboModel.TFilter} filter - The filter criteria to apply when counting records
197
+ * @param {DoboModel.TOptions} options - The options object
198
+ */
199
+
200
+ /**
201
+ * Hook that is called after counting records.
202
+ *
203
+ * @memberof module:Hook
204
+ * @method
205
+ * @async
206
+ * @name dobo:afterCountRecord
207
+ * @param {DoboModel} model - The model instance
208
+ * @param {DoboModel.TFilter} filter - The filter criteria that was applied when counting records
209
+ * @param {DoboModel.TResultCountRecord} result - The result of the count operation
210
+ * @param {DoboModel.TOptions} options - The options object
211
+ */
212
+
213
+ /**
214
+ * Hook that is called before getting a record by ID.
215
+ *
216
+ * @memberof module:Hook
217
+ * @method
218
+ * @async
219
+ * @name dobo:beforeGetRecord
220
+ * @param {DoboModel} model - The model instance
221
+ * @param {string|number} id - The ID of the record to be retrieved
222
+ * @param {DoboModel.TOptions} options - The options object
223
+ */
224
+
225
+ /**
226
+ * Hook that is called after getting a record by ID.
227
+ *
228
+ * @memberof module:Hook
229
+ * @method
230
+ * @async
231
+ * @name dobo:afterGetRecord
232
+ * @param {DoboModel} model - The model instance
233
+ * @param {string|number} id - The ID of the record that was retrieved
234
+ * @param {DoboModel.TResultGetRecord} result - The result of the get operation
235
+ * @param {DoboModel.TOptions} options - The options object
236
+ */
237
+
238
+ export default {}
@@ -86,7 +86,7 @@
86
86
  "methodUnsupported%s%s": "Method '%s@%s' is unsupported",
87
87
  "uniqueConstraintError": "Unique constraint error",
88
88
  "taskMustHaveModel%s": "Task must have %s model",
89
- "driverNotInstalled%s": "Problem with '%s' driver file. Not installed yet?",
89
+ "adapterNotInstalled%s": "Problem with '%s' adapter file. Not installed yet?",
90
90
  "generalDbError": "General Database Error",
91
91
  "dbConstrainError": "Database Constraint Error",
92
92
  "onlySupportThese%s": "Only support one of these: %s",
@@ -97,9 +97,9 @@
97
97
  "addingMemoryPersistenceIgnored": "'%s' is a memory persistence model. Adding records from fixture is ignored!",
98
98
  "onlyOneConnType%s": "There could only be one connection type '%s'",
99
99
  "unsupportedDbType%s": "Unsupported DB type '%s'",
100
- "driverMustProvideDbType": "A DB driver must provide at least one database type",
101
- "driverMustHaveName": "A DB driver must have a driver name",
102
- "dbTypeAlreadySupportedByDriver%s%s": "Database type '%s' already supported by driver '%s'",
100
+ "adapterMustProvideDbType": "A DB adapter must provide at least one database type",
101
+ "adapterMustHaveName": "A DB adapter must have a adapter name",
102
+ "dbTypeAlreadySupportedByAdapter%s%s": "Database type '%s' already supported by adapter '%s'",
103
103
  "invalidFeatureHandler%s%s": "Invalid handler for feature '%s:%s'",
104
104
  "unsupportedIndexType%s%s%s%s": "Unsupported index type %s for '%s@%s'. Allowed values: %s",
105
105
  "unknownFeature%s%s": "'Unknown feature '%s@%s'",
@@ -123,25 +123,25 @@
123
123
  "db": "DB",
124
124
  "invalidQuery": "Invalid Query",
125
125
  "noResultFound": "No result found",
126
- "invalidDriverClassFactory%s%s": "Invalid driver class factory '%s:%s'",
127
- "invalidDriverClass%s%s": "Invalid driver class '%s:%s'",
126
+ "invalidAdapterClassFactory%s%s": "Invalid adapter class factory '%s:%s'",
127
+ "invalidAdapterClass%s%s": "Invalid adapter class '%s:%s'",
128
128
  "multipleConnection%s": "Model '%s' is attached to more than one connection",
129
129
  "invalidFeature%s%s": "Invalid feature '%s@%s'",
130
130
  "invalidModelExtender%s%s": "Invalid model extender '%s' on '%s'",
131
- "unknownDbDriver%s": "Unknown database driver '%s'",
131
+ "unknownDbAdapter%s": "Unknown database adapter '%s'",
132
132
  "unknownPropType%s%s": "Unknown property type '%s' on '%s'",
133
133
  "unknownIndexType%s%s": "Unknown index type '%s' on '%s'",
134
134
  "unknownPropNameOnIndex%s%s": "Unknown property name '%s' on index for '%s'",
135
135
  "unknownModelForRef%s%s%s": "Unknown model for reference '%s' on '%s:%s'",
136
136
  "unknownPropForRef%s%s%s": "Unknown property for reference '%s:%s' on '%s:%s'",
137
- "noConnectionUsingDriver%s": "No connection using driver '%s'. To save resource, disabling this driver/plugin is recommended",
137
+ "noConnectionUsingAdapter%s": "No connection using adapter '%s'. To save resource, disabling this adapter/plugin is recommended",
138
138
  "keyIsRequired%s%s%s": "Key '%s' on %s|toLower '%s' is required",
139
139
  "enterRecordId": "Enter record ID:",
140
140
  "allowedPropType%s%s": "Allowed property type for field '%s': %s",
141
141
  "invalidIdType%s%s": "Invalid ID type for '%s'. Please only use one of these: %s",
142
142
  "noDefaultConnection": "No default connection found. All models will use the built-in memory database instead",
143
143
  "recordImmutable%s%s": "Record with ID: '%s' & model: '%s' is immutable and can't be modified or deleted",
144
- "notSupportedDriver%s%s%s": "%s|upperFirst '%s' is not supported by driver '%s'",
144
+ "notSupportedAdapter%s%s%s": "%s|upperFirst '%s' is not supported by adapter '%s'",
145
145
  "inMemoryDb%s%s": "'%s' is an in-memory database, %s is not allowed",
146
146
  "buildOp": "'build' operation",
147
147
  "dropOp": "'drop' operation",
@@ -85,7 +85,7 @@
85
85
  "methodUnsupported%s%s": "Method '%s@%s' is unsupported",
86
86
  "uniqueConstraintError": "Unique constraint error",
87
87
  "taskMustHaveModel%s": "Task must have %s model",
88
- "driverNotInstalled%s": "Problem with '%s' driver file. Not installed yet?",
88
+ "adapterNotInstalled%s": "Problem with '%s' adapter file. Not installed yet?",
89
89
  "generalDbError": "General Database Error",
90
90
  "dbConstrainError": "Database Constraint Error",
91
91
  "onlySupportThese%s": "Only support one of these: %s",
@@ -96,9 +96,9 @@
96
96
  "addingMemoryPersistenceIgnored": "'%s' is a memory persistence model. Adding records from fixture is ignored!",
97
97
  "onlyOneConnType%s": "There could only be one connection type '%s'",
98
98
  "unsupportedDbType%s": "Unsupported DB type '%s'",
99
- "driverMustProvideDbType": "A DB driver must provide at least one database type",
100
- "driverMustHaveName": "A DB driver must have a driver name",
101
- "dbTypeAlreadySupportedByDriver%s%s": "Database type '%s' already supported by driver '%s'",
99
+ "adapterMustProvideDbType": "A DB adapter must provide at least one database type",
100
+ "adapterMustHaveName": "A DB adapter must have a adapter name",
101
+ "dbTypeAlreadySupportedByAdapter%s%s": "Database type '%s' already supported by adapter '%s'",
102
102
  "invalidFeatureHandler%s%s": "Handler untuk fitur '%s:%s' tidak valid",
103
103
  "unsupportedIndexType%s%s%s%s": "Unsupported index type %s for '%s@%s'. Allowed values: %s",
104
104
  "unknownFeature%s%s": "'Unknown feature '%s@%s'",
@@ -122,25 +122,25 @@
122
122
  "db": "DB",
123
123
  "invalidQuery": "Kueri Tidak Valid",
124
124
  "noResultFound": "Tidak ditemukan hasil",
125
- "invalidDriverClass%s%s": "Kelas driver '%s:%s' tidak valid",
126
- "invalidDriverClassFactory%s%s": "Faktori kelas driver '%s:%s' tidak valid",
125
+ "invalidAdapterClass%s%s": "Kelas adapter '%s:%s' tidak valid",
126
+ "invalidAdapterClassFactory%s%s": "Faktori kelas adapter '%s:%s' tidak valid",
127
127
  "multipleConnection%s": "Model '%s' terhubung dengan lebih dari satu koneksi",
128
128
  "invalidFeature%s%s": "Fitur tidak '%s@%s' valid",
129
129
  "invalidModelExtender%s%s": "Extender skema '%s@%s' tidak valid",
130
- "unknownDbDriver%s": "Driver database '%s' tidak dikenal",
130
+ "unknownDbAdapter%s": "Adapter database '%s' tidak dikenal",
131
131
  "unknownPropType%s%s": "Tipe properti '%s' di '%s' tidak dikenal",
132
132
  "unknownIndexType%s%s": "Tipe index '%s' di '%s' tidak dikenal",
133
133
  "unknownPropNameOnIndex%s%s": "Nama properti '%s' di index untuk '%s' tidak dikenal",
134
134
  "unknownModelForRef%s%s%s": "Unknown model for reference '%s' on '%s:%s'",
135
135
  "unknownPropForRef%s%s%s": "Unknown property for reference '%s:%s' on '%s:%s'",
136
- "noConnectionUsingDriver%s": "No connection using driver '%s'. To save resource, disabling this driver/plugin is recommended",
136
+ "noConnectionUsingAdapter%s": "No connection using adapter '%s'. To save resource, disabling this adapter/plugin is recommended",
137
137
  "keyIsRequired%s%s%s": "Key '%s' on %s|toLower '%s' is required",
138
138
  "enterRecordId": "Enter record ID:",
139
139
  "allowedPropType%s%s": "Allowed property type for field '%s': %s",
140
140
  "invalidIdType%s%s": "Invalid ID type for '%s'. Please only use one of these: %s",
141
141
  "noDefaultConnection": "No default connection found. All models will use the built-in memory database instead",
142
142
  "recordImmutable%s%s": "Data dengan ID: '%s' & model: '%s' adalah immutable dan tidak bisa diubah atau dihapus",
143
- "notSupportedDriver%s%s%s": "%s|upperFirst '%s' tidak didukung oleh driver '%s'",
143
+ "notSupportedAdapter%s%s%s": "%s|upperFirst '%s' tidak didukung oleh adapter '%s'",
144
144
  "inMemoryDb%s%s": "'%s' adalah database in-memory, %s tidak diizinkan",
145
145
  "buildOp": "operasi 'build'",
146
146
  "dropOp": "operasi 'drop'",
@@ -35,7 +35,7 @@ async function modelRebuild (path, ...args) {
35
35
  for (const s of names) {
36
36
  const model = this.getModel(s)
37
37
  const spin = this.print.spinner().start('rebuilding%s', model.name)
38
- if (model.driver.memory) {
38
+ if (model.adapter.memory) {
39
39
  spin.warn('memoryDbSkipped%s', model.name)
40
40
  continue
41
41
  }
@@ -71,7 +71,7 @@ async function modelRebuild (path, ...args) {
71
71
  for (const s of without(names, ...skipped)) {
72
72
  const model = this.getModel(s)
73
73
  const spin = this.print.spinner().start('addingFixture%s', model.name)
74
- if (model.driver.memory) {
74
+ if (model.adapter.memory) {
75
75
  spin.warn('memoryDbSkipped%s', model.name)
76
76
  continue
77
77
  }
@@ -1,11 +1,11 @@
1
1
  import { Query } from 'mingo'
2
2
 
3
- async function memoryDriverFactory () {
4
- const { DoboDriver } = this.app.baseClass
3
+ async function memoryAdapterFactory () {
4
+ const { DoboAdapter } = this.app.baseClass
5
5
  const { findIndex, pullAt, omit, has } = this.app.lib._
6
6
  const { defaultsDeep } = this.app.lib.aneka
7
7
 
8
- class DoboMemoryDriver extends DoboDriver {
8
+ class DoboMemoryAdapter extends DoboAdapter {
9
9
  constructor (plugin, name, options) {
10
10
  super(plugin, name, options)
11
11
  this.idGenerator = 'ulid'
@@ -165,8 +165,8 @@ async function memoryDriverFactory () {
165
165
  }
166
166
  }
167
167
 
168
- this.app.baseClass.DoboMemoryDriver = DoboMemoryDriver
169
- return DoboMemoryDriver
168
+ this.app.baseClass.DoboMemoryAdapter = DoboMemoryAdapter
169
+ return DoboMemoryAdapter
170
170
  }
171
171
 
172
- export default memoryDriverFactory
172
+ export default memoryAdapterFactory
@@ -1,7 +1,7 @@
1
1
  async function beforeRemoveRecord (id, opts, options) {
2
2
  const { get } = this.app.lib._
3
3
  if (get(options, 'req.user.isXSiteAdmin')) return
4
- const record = await this.driver.getRecord(this, id)
4
+ const record = await this.adapter.getRecord(this, id)
5
5
  const immutable = get(record.data, opts.field)
6
6
  if (immutable.length === 1 && immutable[0] === '*') throw this.plugin.error('recordImmutable%s%s', id, this.name, { statusCode: 423 })
7
7
  }
@@ -9,7 +9,7 @@ async function beforeRemoveRecord (id, opts, options) {
9
9
  async function beforeUpdateRecord (id, body, opts, options) {
10
10
  const { get } = this.app.lib._
11
11
  if (get(options, 'req.user.isXSiteAdmin')) return
12
- const record = await this.driver.getRecord(this, id)
12
+ const record = await this.adapter.getRecord(this, id)
13
13
  const immutable = get(record.data, opts.field)
14
14
  if (immutable.length === 0) return
15
15
  const fields = []
@@ -60,7 +60,7 @@ async function removedAt (opts = {}) {
60
60
  handler: async function (id, options) {
61
61
  const { set } = this.app.lib._
62
62
  const body = set({}, opts.field, new Date())
63
- const record = await this.driver.recordUpdate(this, id, body, { noResult: false })
63
+ const record = await this.adapter.recordUpdate(this, id, body, { noResult: false })
64
64
  options.record = { oldData: record.oldData }
65
65
  }
66
66
  }]
package/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import nql from '@tryghost/nql'
2
- import collectConnections from './lib/collect-connections.js'
3
- import collectDrivers from './lib/collect-drivers.js'
4
- import collectFeatures from './lib/collect-features.js'
5
- import collectModels from './lib/collect-models.js'
2
+ import {
3
+ collectConnections, collectAdapters, collectFeatures, collectModels
4
+ } from './lib/helper.js'
6
5
 
7
6
  /**
8
7
  * @typedef {Object} TPropertyType
8
+ * @memberof DoboModel
9
9
  * @property {Object} integer
10
10
  * @property {string} [integer.validator=number]
11
11
  * @property {Object} smallint
@@ -87,6 +87,9 @@ const commonPropertyTypes = ['name', 'type', 'required', 'rules', 'validator', '
87
87
  /**
88
88
  * Plugin factory
89
89
  *
90
+ * @name pluginFactory
91
+ * @async
92
+ * @method
90
93
  * @param {string} pkgName - NPM package name
91
94
  * @returns {class}
92
95
  */
@@ -99,7 +102,7 @@ async function factory (pkgName) {
99
102
  /**
100
103
  * Dobo Database Framework for {@link https://github.com/ardhi/bajo|Bajo}.
101
104
  *
102
- * See {@tutorial ecosystem} for available drivers & tools
105
+ * See {@tutorial ecosystem} for available adapters & tools
103
106
  *
104
107
  * @class
105
108
  */
@@ -174,7 +177,7 @@ async function factory (pkgName) {
174
177
  /**
175
178
  * @type {Object[]}
176
179
  */
177
- this.drivers = []
180
+ this.adapters = []
178
181
 
179
182
  /**
180
183
  * @type {Object[]}
@@ -213,19 +216,19 @@ async function factory (pkgName) {
213
216
  * @returns {string[]}
214
217
  */
215
218
 
216
- getAllPropertyKeys = (driver) => {
219
+ getAllPropertyKeys = (adapter) => {
217
220
  const { uniq, isEmpty } = this.app.lib._
218
221
  const keys = [...commonPropertyTypes]
219
222
  for (const type in propertyType) {
220
223
  keys.push(...Object.keys(propertyType[type]))
221
224
  }
222
- if (driver && !isEmpty(driver.constructor.propertyKeys)) keys.push(...driver.constructor.propertyKeys)
225
+ if (adapter && !isEmpty(adapter.constructor.propertyKeys)) keys.push(...adapter.constructor.propertyKeys)
223
226
  return uniq(keys)
224
227
  }
225
228
 
226
229
  /**
227
230
  * Initialize plugin and performing the following tasks:
228
- * - {@link module:Lib.collectDrivers|Collecting all drivers}
231
+ * - {@link module:Lib.collectAdapters|Collecting all adapters}
229
232
  * - {@link module:Lib.collectConnections|Collecting all connections}
230
233
  * - {@link module:Lib.collectFeatures|Collecting all features}
231
234
  * - {@link module:Lib.collectModels|Collecting all models}
@@ -234,7 +237,7 @@ async function factory (pkgName) {
234
237
  */
235
238
  init = async () => {
236
239
  const { fs } = this.app.lib
237
- await collectDrivers.call(this)
240
+ await collectAdapters.call(this)
238
241
  await collectConnections.call(this)
239
242
  await collectFeatures.call(this)
240
243
  await collectModels.call(this)
@@ -257,7 +260,7 @@ async function factory (pkgName) {
257
260
  this.log.debug('dbInit')
258
261
  for (const connection of conns) {
259
262
  await connection.connect(noRebuild)
260
- this.log.trace('dbInit%s%s%s', connection.driver.plugin.ns, connection.driver.name, connection.name)
263
+ this.log.trace('dbInit%s%s%s', connection.adapter.plugin.ns, connection.adapter.name, connection.name)
261
264
  }
262
265
  }
263
266
 
@@ -266,7 +269,7 @@ async function factory (pkgName) {
266
269
  *
267
270
  * @param {string} name - Connection name
268
271
  * @param {boolean} [silent] - If ```true``` and connection is not found, it won't throw error
269
- * @returns {Driver} Return connection instance or ```undefined``` if silent is ```true```
272
+ * @returns {Adapter} Return connection instance or ```undefined``` if silent is ```true```
270
273
  */
271
274
  getConnection = (name, silent) => {
272
275
  const conn = find(this.connections, { name })
@@ -275,35 +278,35 @@ async function factory (pkgName) {
275
278
  }
276
279
 
277
280
  /**
278
- * Get driver by name. It returns the first driver named after "{name}"
281
+ * Get adapter by name. It returns the first adapter named after "{name}"
279
282
  *
280
- * Also support NsPath format for those who load the same named driver but from different provider/plugin.
283
+ * Also support NsPath format for those who load the same named adapter but from different provider/plugin.
281
284
  *
282
- * @param {string} name - Driver name
283
- * @param {boolean} [silent] - If ```true``` and driver is not found, it won't throw error
284
- * @returns {Driver} Returns driver instance or ```undefined``` if silent is ```true```
285
+ * @param {string} name - Adapter name
286
+ * @param {boolean} [silent] - If ```true``` and adapter is not found, it won't throw error
287
+ * @returns {Adapter} Returns adapter instance or ```undefined``` if silent is ```true```
285
288
  */
286
- getDriver = (name, silent) => {
289
+ getAdapter = (name, silent) => {
287
290
  const { breakNsPath } = this.app.bajo
288
- let driver
291
+ let adapter
289
292
  if (!name.includes(':')) {
290
- driver = find(this.drivers, { name })
291
- if (driver) return driver
292
- driver = filter(this.drivers, d => d.plugin.ns === name)
293
- if (driver.length === 1) return driver[0]
294
- if (!silent) throw this.error('unknown%s%s', this.t('driver'), name)
293
+ adapter = find(this.adapters, { name })
294
+ if (adapter) return adapter
295
+ adapter = filter(this.adapters, d => d.plugin.ns === name)
296
+ if (adapter.length === 1) return adapter[0]
297
+ if (!silent) throw this.error('unknown%s%s', this.t('adapter'), name)
295
298
  return
296
299
  }
297
300
  const { ns, path } = breakNsPath(name)
298
- driver = find(this.drivers, d => d.name === path && d.plugin.ns === ns)
299
- if (!driver && !silent) throw this.error('unknown%s%s', this.t('driver'), name)
300
- return driver
301
+ adapter = find(this.adapters, d => d.name === path && d.plugin.ns === ns)
302
+ if (!adapter && !silent) throw this.error('unknown%s%s', this.t('adapter'), name)
303
+ return adapter
301
304
  }
302
305
 
303
306
  /**
304
- * Get feature by name. It returns the first driver named after "{name}"
307
+ * Get feature by name. It returns the first adapter named after "{name}"
305
308
  *
306
- * Also support NsPath format for those who load the same named driver but from different provider/plugin.
309
+ * Also support NsPath format for those who load the same named adapter but from different provider/plugin.
307
310
  *
308
311
  * @param {string} - Feature name
309
312
  * @returns {Feature} Return feature instance
@@ -591,7 +594,7 @@ async function factory (pkgName) {
591
594
  }
592
595
  }
593
596
  let strQ = this.replaceRegexInJson(result)
594
- if (model && model.driver.idField.name !== 'id') strQ = strQ.replaceAll('"id"', `"${model.driver.idField.name}"`)
597
+ if (model && model.adapter.idField.name !== 'id') strQ = strQ.replaceAll('"id"', `"${model.adapter.idField.name}"`)
595
598
  try {
596
599
  result = this.reviveRegexInJson(strQ)
597
600
  } catch (err) {}