@bedrockio/model 0.22.0 → 0.22.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.22.1
2
+
3
+ - Indicate whether document was created or not in upsert.
4
+
1
5
  ## 0.22.0
2
6
 
3
7
  - Removed regex parsing in search.
@@ -16,8 +16,10 @@ function applyUpsert(schema) {
16
16
  if (doc) {
17
17
  doc.assign(fields);
18
18
  await doc.save();
19
+ doc.$locals.created = false;
19
20
  } else {
20
21
  doc = await this.create(fields);
22
+ doc.$locals.created = true;
21
23
  }
22
24
  return doc;
23
25
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrockio/model",
3
- "version": "0.22.0",
3
+ "version": "0.22.1",
4
4
  "description": "Bedrock utilities for model creation.",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/upsert.js CHANGED
@@ -12,8 +12,10 @@ export function applyUpsert(schema) {
12
12
  if (doc) {
13
13
  doc.assign(fields);
14
14
  await doc.save();
15
+ doc.$locals.created = false;
15
16
  } else {
16
17
  doc = await this.create(fields);
18
+ doc.$locals.created = true;
17
19
  }
18
20
 
19
21
  return doc;
@@ -1 +1 @@
1
- {"version":3,"file":"upsert.d.ts","sourceRoot":"","sources":["../../src/upsert.js"],"names":[],"mappings":"AAAA,+CAgCC"}
1
+ {"version":3,"file":"upsert.d.ts","sourceRoot":"","sources":["../../src/upsert.js"],"names":[],"mappings":"AAAA,+CAkCC"}