@bedrockio/model 0.2.11 → 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 => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrockio/model",
3
- "version": "0.2.11",
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) {