@bedrockio/model 0.2.10 → 0.2.12

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.
@@ -169,9 +169,11 @@ function buildKeywordQuery(schema, keyword, fields) {
169
169
  _id: keyword
170
170
  });
171
171
  }
172
- return {
172
+
173
+ // Note: Mongo will error on empty $or/$and array.
174
+ return queries.length ? {
173
175
  $or: queries
174
- };
176
+ } : {};
175
177
  }
176
178
  function buildRegexQuery(keyword, fields) {
177
179
  return fields.map(field => {
@@ -146,6 +146,7 @@ function applyValidation(schema, definition) {
146
146
  });
147
147
  schema.static('getBaseSchema', function getBaseSchema() {
148
148
  return getSchemaFromMongoose(schema, {
149
+ model: this,
149
150
  stripDeleted: true,
150
151
  requireReadAccess: true
151
152
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrockio/model",
3
- "version": "0.2.10",
3
+ "version": "0.2.12",
4
4
  "description": "Bedrock utilities for model creation.",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/search.js CHANGED
@@ -179,7 +179,8 @@ function buildKeywordQuery(schema, keyword, fields) {
179
179
  queries.push({ _id: keyword });
180
180
  }
181
181
 
182
- return { $or: queries };
182
+ // Note: Mongo will error on empty $or/$and array.
183
+ return queries.length ? { $or: queries } : {};
183
184
  }
184
185
 
185
186
  function buildRegexQuery(keyword, fields) {
package/src/validation.js CHANGED
@@ -163,6 +163,7 @@ export function applyValidation(schema, definition) {
163
163
 
164
164
  schema.static('getBaseSchema', function getBaseSchema() {
165
165
  return getSchemaFromMongoose(schema, {
166
+ model: this,
166
167
  stripDeleted: true,
167
168
  requireReadAccess: true,
168
169
  });
@@ -1 +1 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.js"],"names":[],"mappings":"AAiFA,kDAEC;AAED,oEAoFC;AAsBD,wEAkBC;AAySD;;;EAEC;AAED;;;EAOC;AAnfD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQK"}
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.js"],"names":[],"mappings":"AAiFA,kDAEC;AAED,oEAqFC;AAsBD,wEAkBC;AAySD;;;EAEC;AAED;;;EAOC;AApfD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQK"}