@bedrockio/model 0.1.7 → 0.1.8

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.
@@ -16,9 +16,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
16
16
  // @ts-ignore
17
17
  // Overloading mongoose Query prototype to
18
18
  // allow an "include" method for queries.
19
- _mongoose.default.Query.prototype.include = function include(paths) {
20
- const filter = this.getFilter();
21
- filter.include = paths;
19
+ _mongoose.default.Query.prototype.include = function include(arg) {
20
+ if (arg) {
21
+ const filter = this.getFilter();
22
+ filter.include = arg;
23
+ }
22
24
  return this;
23
25
  };
24
26
  const DESCRIPTION = 'Field to be selected or populated.';
@@ -114,6 +114,9 @@ function applyValidation(schema, definition) {
114
114
  model: this
115
115
  });
116
116
  });
117
+ schema.static('getIncludeValidation', function getIncludeValidation() {
118
+ return _include.INCLUDE_FIELD_SCHEMA;
119
+ });
117
120
  schema.static('getBaseSchema', function getBaseSchema() {
118
121
  return getSchemaFromMongoose(schema);
119
122
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrockio/model",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Bedrock utilities for model creation.",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/include.js CHANGED
@@ -8,9 +8,11 @@ import { POPULATE_MAX_DEPTH } from './const';
8
8
  // @ts-ignore
9
9
  // Overloading mongoose Query prototype to
10
10
  // allow an "include" method for queries.
11
- mongoose.Query.prototype.include = function include(paths) {
12
- const filter = this.getFilter();
13
- filter.include = paths;
11
+ mongoose.Query.prototype.include = function include(arg) {
12
+ if (arg) {
13
+ const filter = this.getFilter();
14
+ filter.include = arg;
15
+ }
14
16
  return this;
15
17
  };
16
18
 
package/src/validation.js CHANGED
@@ -126,6 +126,10 @@ export function applyValidation(schema, definition) {
126
126
  }
127
127
  );
128
128
 
129
+ schema.static('getIncludeValidation', function getIncludeValidation() {
130
+ return INCLUDE_FIELD_SCHEMA;
131
+ });
132
+
129
133
  schema.static('getBaseSchema', function getBaseSchema() {
130
134
  return getSchemaFromMongoose(schema);
131
135
  });
@@ -1 +1 @@
1
- {"version":3,"file":"include.d.ts","sourceRoot":"","sources":["../src/include.js"],"names":[],"mappings":"AAyBA,gDAoCC;AAMD,uDA4BC;AAGD,2DAIC;AApFD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKG"}
1
+ {"version":3,"file":"include.d.ts","sourceRoot":"","sources":["../src/include.js"],"names":[],"mappings":"AA2BA,gDAoCC;AAMD,uDA4BC;AAGD,2DAIC;AApFD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKG"}
@@ -1 +1 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.js"],"names":[],"mappings":"AAkEA,kDAEC;AAED,oEA6DC;AAaD,wEAkBC;AA0PD;;;EAEC;AAED;;;EAOC;AA/YD,8EAUK"}
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.js"],"names":[],"mappings":"AAkEA,kDAEC;AAED,oEAiEC;AAaD,wEAkBC;AA0PD;;;EAEC;AAED;;;EAOC;AAnZD,8EAUK"}