@bedrockio/model 0.18.6 → 0.19.0

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.19.0
2
+
3
+ - Ensure that document clone is synchronous.
4
+
1
5
  ## 0.18.6
2
6
 
3
7
  - Yada bump.
package/README.md CHANGED
@@ -1785,9 +1785,7 @@ shop.name; // Now "My New Shop"
1785
1785
 
1786
1786
  ### Clone
1787
1787
 
1788
- Adds a single `clone` method on documents. This is an async method mostly for
1789
- testing that will immediately create a copy of the document. It makes up for
1790
- some of the shortcomings of the Mongoose `$clone` method:
1788
+ Adds a single `clone` method on documents that makes up for some of the shortcomings of the Mongoose `$clone` method:
1791
1789
 
1792
1790
  - A new `id` will be generated.
1793
1791
  - Populated and self-referencing documents are handled.
package/dist/cjs/clone.js CHANGED
@@ -13,11 +13,11 @@ exports.applyClone = applyClone;
13
13
  // - Cannot deal with unique fields.
14
14
  //
15
15
  function applyClone(schema) {
16
- schema.method('clone', async function clone() {
17
- return await cloneDocument(this);
16
+ schema.method('clone', function clone() {
17
+ return cloneDocument(this);
18
18
  });
19
19
  }
20
- async function cloneDocument(doc) {
20
+ function cloneDocument(doc) {
21
21
  const Model = doc.constructor;
22
22
  const clone = new Model();
23
23
  for (let [key, typedef] of Object.entries(Model.schema.obj)) {
@@ -31,7 +31,6 @@ async function cloneDocument(doc) {
31
31
  }
32
32
  clone.set(key, value);
33
33
  }
34
- await clone.save();
35
34
  return clone;
36
35
  }
37
36
  let counter = 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrockio/model",
3
- "version": "0.18.6",
3
+ "version": "0.19.0",
4
4
  "description": "Bedrock utilities for model creation.",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/clone.js CHANGED
@@ -7,12 +7,12 @@
7
7
  // - Cannot deal with unique fields.
8
8
  //
9
9
  export function applyClone(schema) {
10
- schema.method('clone', async function clone() {
11
- return await cloneDocument(this);
10
+ schema.method('clone', function clone() {
11
+ return cloneDocument(this);
12
12
  });
13
13
  }
14
14
 
15
- async function cloneDocument(doc) {
15
+ function cloneDocument(doc) {
16
16
  const Model = doc.constructor;
17
17
  const clone = new Model();
18
18
 
@@ -26,8 +26,6 @@ async function cloneDocument(doc) {
26
26
  clone.set(key, value);
27
27
  }
28
28
 
29
- await clone.save();
30
-
31
29
  return clone;
32
30
  }
33
31
 
package/types/schema.d.ts CHANGED
@@ -19,7 +19,6 @@ export function createSchema(definition: object, options?: mongoose.SchemaOption
19
19
  };
20
20
  collation?: mongoose.mongo.CollationOptions;
21
21
  collectionOptions?: mongoose.mongo.CreateCollectionOptions;
22
- lean?: boolean | mongoose.LeanOptions;
23
22
  timeseries?: mongoose.mongo.TimeSeriesCollectionOptions;
24
23
  expireAfterSeconds?: number;
25
24
  expires?: number | string;
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.js"],"names":[],"mappings":"AAyBA;;;;;;;GAOG;AACH,yCAJW,MAAM,YACN,QAAQ,CAAC,aAAa;;;;;;;YA2C7B,CAAC;WAAa,CAAC;mBACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;SAqIH,CAAC;gBACL,CAAC;SAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAjItB;AAED,iEAcC;qBA9FoB,UAAU"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.js"],"names":[],"mappings":"AAyBA;;;;;;;GAOG;AACH,yCAJW,MAAM,YACN,QAAQ,CAAC,aAAa;;;;;;;YA2C7B,CAAC;WAAa,CAAC;mBACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;SAgIb,CAAC;gBAA4B,CAAA;SAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA3H5C;AAED,iEAcC;qBA9FoB,UAAU"}