@bedrockio/model 0.13.0 → 0.13.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/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.13.1
2
+
3
+ - Do not enforce unique constraints in search validation.
4
+
1
5
  ## 0.13.0
2
6
 
3
7
  - Removed support for passing schemas into `getCreateValidation` etc. now that
@@ -58,6 +58,7 @@ function applyValidation(schema, definition) {
58
58
  return getSchemaFromMongoose(schema, {
59
59
  model: this,
60
60
  stripEmpty: true,
61
+ applyUnique: true,
61
62
  stripDeleted: true,
62
63
  allowInclude: false,
63
64
  stripTimestamps: true,
@@ -71,6 +72,7 @@ function applyValidation(schema, definition) {
71
72
  return getSchemaFromMongoose(schema, {
72
73
  model: this,
73
74
  allowNull: true,
75
+ applyUnique: true,
74
76
  skipRequired: true,
75
77
  stripUnknown: true,
76
78
  stripDeleted: true,
@@ -304,7 +306,7 @@ function getSchemaForTypedef(typedef, options = {}) {
304
306
  if (typedef.writeAccess && options.requireWriteAccess) {
305
307
  schema = validateAccess('write', schema, typedef.writeAccess, options);
306
308
  }
307
- if (typedef.softUnique) {
309
+ if (typedef.softUnique && options.applyUnique) {
308
310
  schema = schema.custom(async (value, {
309
311
  path,
310
312
  originalRoot
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrockio/model",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "description": "Bedrock utilities for model creation.",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/validation.js CHANGED
@@ -60,6 +60,7 @@ export function applyValidation(schema, definition) {
60
60
  return getSchemaFromMongoose(schema, {
61
61
  model: this,
62
62
  stripEmpty: true,
63
+ applyUnique: true,
63
64
  stripDeleted: true,
64
65
  allowInclude: false,
65
66
  stripTimestamps: true,
@@ -74,6 +75,7 @@ export function applyValidation(schema, definition) {
74
75
  return getSchemaFromMongoose(schema, {
75
76
  model: this,
76
77
  allowNull: true,
78
+ applyUnique: true,
77
79
  skipRequired: true,
78
80
  stripUnknown: true,
79
81
  stripDeleted: true,
@@ -326,7 +328,7 @@ function getSchemaForTypedef(typedef, options = {}) {
326
328
  schema = validateAccess('write', schema, typedef.writeAccess, options);
327
329
  }
328
330
 
329
- if (typedef.softUnique) {
331
+ if (typedef.softUnique && options.applyUnique) {
330
332
  schema = schema.custom(async (value, { path, originalRoot }) => {
331
333
  const { id } = originalRoot;
332
334
  await assertUnique({
@@ -1 +1 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.js"],"names":[],"mappings":"AAqDA,kDAEC;AAED,oEAyFC;AAsBD,wEAiBC;AA8SD;;;EAEC;AAED;;;EAOC"}
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.js"],"names":[],"mappings":"AAqDA,kDAEC;AAED,oEA2FC;AAsBD,wEAiBC;AA8SD;;;EAEC;AAED;;;EAOC"}