cosa 7.0.0 → 7.1.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.
Files changed (2) hide show
  1. package/lib/model.js +4 -2
  2. package/package.json +7 -7
package/lib/model.js CHANGED
@@ -18,7 +18,7 @@ Immutable.use(Date, require('./date'));
18
18
  Immutable.use('objectid', require('./bson-objectId'));
19
19
  Immutable.use(require('./object'));
20
20
 
21
- const isNotVirtual = complement(pathEq([ 'type' ], 'virtual'));
21
+ const isNotVirtual = complement(pathEq('virtual', [ 'type' ]));
22
22
  const removeMeta = omit(['__modified', '__original']);
23
23
 
24
24
  const db = require('./db');
@@ -124,6 +124,9 @@ const _create = (data, definition) => {
124
124
  return context;
125
125
  }
126
126
  let obj = context.toObject();
127
+ if (explicitId && context.isNew()) {
128
+ obj._id = explicitId;
129
+ }
127
130
  if ('function' === typeof context.beforeSave) {
128
131
  await context.beforeSave.apply(obj, [options]);
129
132
  }
@@ -156,7 +159,6 @@ const _create = (data, definition) => {
156
159
  }, { silent: true });
157
160
  } else {
158
161
  obj._etag = newEtag;
159
- if (explicitId) { obj._id = explicitId; }
160
162
  debug(`inserting into ${collection}: ${JSON.stringify(obj)}`);
161
163
  try {
162
164
  result = await db.insert(collection, obj, options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cosa",
3
- "version": "7.0.0",
3
+ "version": "7.1.1",
4
4
  "description": "Cosa Models for MongoDB",
5
5
  "main": "lib/index.js",
6
6
  "engines": {
@@ -40,19 +40,19 @@
40
40
  "debug": "^4.3.4",
41
41
  "error": "^7.0.2",
42
42
  "etag": "^1.8.1",
43
- "joi": "^17.8.3",
44
- "mongodb": "~4.14.0",
43
+ "joi": "^17.9.2",
44
+ "mongodb": "~4.16.0",
45
45
  "object-path": "^0.11.8",
46
- "omnibelt": "^2.1.0"
46
+ "omnibelt": "^3.1.2"
47
47
  },
48
48
  "devDependencies": {
49
- "@losant/eslint-config-losant": "^1.6.0",
49
+ "@losant/eslint-config-losant": "^1.6.1",
50
50
  "husky": "^8.0.3",
51
- "lint-staged": "^13.1.2",
51
+ "lint-staged": "~13.2.3",
52
52
  "chai": "^4.3.7",
53
53
  "chai-as-promised": "^7.1.1",
54
54
  "chai-datetime": "^1.8.0",
55
- "documentation": "^14.0.1",
55
+ "documentation": "^14.0.2",
56
56
  "mocha": "^10.2.0",
57
57
  "string-template": "^1.0.0"
58
58
  },