@naturalcycles/db-lib 10.12.0 → 10.13.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.
@@ -952,9 +952,9 @@ export class CommonDao {
952
952
  }
953
953
  const inputName = opt.table || this.cfg.table;
954
954
  const [error, convertedValue] = this.cfg.validateBM(input, {
955
- // Passing `mutateInput` through allows to do opt-in mutation
956
- // for individual operations, e.g `someDao.save(myObj, { mutateInput: true })`,
957
- // while still keeping safe non-mutating behavior by default
955
+ // Passing `mutateInput` through allows to opt-out of mutation
956
+ // for individual operations, e.g `someDao.save(myObj, { mutateInput: false })`
957
+ // Default is undefined (the validation function decides whether to mutate or not).
958
958
  mutateInput: opt.mutateInput,
959
959
  inputName,
960
960
  });
@@ -186,7 +186,11 @@ export interface CommonDaoOptions extends CommonDBOptions {
186
186
  */
187
187
  skipValidation?: boolean;
188
188
  /**
189
- * Default to false.
189
+ * Defaults to undefined.
190
+ *
191
+ * Undefined means that it's up for the underlying validation library (implementation)
192
+ * to mutate or not.
193
+ * E.g joi and zod would deep-clone, while ajv would MUTATE.
190
194
  *
191
195
  * False ensures that the input is not mutated by the Validation function (`validateBM`).
192
196
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/db-lib",
3
3
  "type": "module",
4
- "version": "10.12.0",
4
+ "version": "10.13.0",
5
5
  "dependencies": {
6
6
  "@naturalcycles/js-lib": "^15",
7
7
  "@naturalcycles/nodejs-lib": "^15"
@@ -227,7 +227,11 @@ export interface CommonDaoOptions extends CommonDBOptions {
227
227
  skipValidation?: boolean
228
228
 
229
229
  /**
230
- * Default to false.
230
+ * Defaults to undefined.
231
+ *
232
+ * Undefined means that it's up for the underlying validation library (implementation)
233
+ * to mutate or not.
234
+ * E.g joi and zod would deep-clone, while ajv would MUTATE.
231
235
  *
232
236
  * False ensures that the input is not mutated by the Validation function (`validateBM`).
233
237
  *
@@ -1222,9 +1222,9 @@ export class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity = BM, I
1222
1222
  const inputName = opt.table || this.cfg.table
1223
1223
 
1224
1224
  const [error, convertedValue] = this.cfg.validateBM(input as BM, {
1225
- // Passing `mutateInput` through allows to do opt-in mutation
1226
- // for individual operations, e.g `someDao.save(myObj, { mutateInput: true })`,
1227
- // while still keeping safe non-mutating behavior by default
1225
+ // Passing `mutateInput` through allows to opt-out of mutation
1226
+ // for individual operations, e.g `someDao.save(myObj, { mutateInput: false })`
1227
+ // Default is undefined (the validation function decides whether to mutate or not).
1228
1228
  mutateInput: opt.mutateInput,
1229
1229
  inputName,
1230
1230
  })