@acodeninja/persist 3.0.0-next.17 → 3.0.0-next.19

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/README.md CHANGED
@@ -9,6 +9,7 @@ A JSON based data modelling and persistence library with alternate storage mecha
9
9
 
10
10
  [![DeepSource](https://app.deepsource.com/gh/acodeninja/persist.svg/?label=active+issues&show_trend=true&token=Vd8_PJuRwwoq4_uBJ0_ymc06)](https://app.deepsource.com/gh/acodeninja/persist/)
11
11
  [![DeepSource](https://app.deepsource.com/gh/acodeninja/persist.svg/?label=code+coverage&show_trend=true&token=Vd8_PJuRwwoq4_uBJ0_ymc06)](https://app.deepsource.com/gh/acodeninja/persist/)
12
+ ![CodeRabbit PR Reviews](https://img.shields.io/coderabbit/prs/github/acodeninja/persist?utm_source=oss&utm_medium=github&utm_campaign=acodeninja%2Fpersist&labelColor=171717&color=FF570A&link=https%3A%2F%2Fcoderabbit.ai&label=CodeRabbit+Reviews)
12
13
 
13
14
  ## Features
14
15
 
@@ -52,6 +53,7 @@ class Person extends Persist.Model {
52
53
 
53
54
  ```javascript
54
55
  import Persist from '@acodeninja/persist';
56
+ import {S3Client} from "@aws-sdk/client-s3";
55
57
  import S3StorageEngine from '@acodeninja/persist/storage/s3';
56
58
 
57
59
  const engine = new S3StorageEngine({
@@ -74,7 +76,7 @@ await connection.put(person);
74
76
  ## Find out more
75
77
 
76
78
  - [Defining Models](./docs/defining-models.md)
77
- - [Model Property Types](./docs/model-properties)
79
+ - [Model Property Types](./docs/model-properties.md)
78
80
  - [Models as Properties](./docs/models-as-properties.md)
79
81
  - [Structured Queries](./docs/structured-queries.md)
80
82
  - [Search Queries](./docs/search-queries.md)
@@ -8,6 +8,7 @@ To store models using an S3 Bucket, use the `S3` storage engine. To use the `S3`
8
8
 
9
9
  ```javascript
10
10
  import Persist from "@acodeninja/persist";
11
+ import {S3Client} from "@aws-sdk/client-s3";
11
12
  import S3StorageEngine from "@acodeninja/persist/storage/s3";
12
13
 
13
14
  const connection = Persist.registerConnection('remote', new S3StorageEngine({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acodeninja/persist",
3
- "version": "3.0.0-next.17",
3
+ "version": "3.0.0-next.19",
4
4
  "description": "A JSON based data modelling and persistence module with alternate storage mechanisms.",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/Connection.js CHANGED
@@ -272,7 +272,7 @@ export default class Connection {
272
272
  if (!Object.keys(this.#models).includes(modelToProcess.constructor.name))
273
273
  throw new ModelNotRegisteredConnectionError(modelToProcess, this.#storage);
274
274
 
275
- const currentModel = modelCache[model.id] ?? await this.get(model.id);
275
+ const currentModel = modelCache[modelToProcess.id] ?? await this.get(modelToProcess.id);
276
276
  modelCache[currentModel.id] = currentModel;
277
277
 
278
278
  if (!modelsToDelete.includes(currentModel.id)) modelsToDelete.push(currentModel.id);
@@ -458,9 +458,11 @@ export default class Connection {
458
458
  }
459
459
  }
460
460
  } catch (error) {
461
- for (const transaction of transactions.filter(t => t.committed && t.original)) {
462
- this.#storage.putModel(transaction.original);
463
- }
461
+ await Promise.all(
462
+ transactions
463
+ .filter(t => t.committed && t.original)
464
+ .map(t => this.#storage.putModel(t.original)),
465
+ );
464
466
 
465
467
  throw new CommitFailedTransactionError(transactions, error);
466
468
  }