@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 +3 -1
- package/docs/storage-engines.md +1 -0
- package/package.json +1 -1
- package/src/Connection.js +6 -4
package/README.md
CHANGED
@@ -9,6 +9,7 @@ A JSON based data modelling and persistence library with alternate storage mecha
|
|
9
9
|
|
10
10
|
[](https://app.deepsource.com/gh/acodeninja/persist/)
|
11
11
|
[](https://app.deepsource.com/gh/acodeninja/persist/)
|
12
|
+

|
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)
|
package/docs/storage-engines.md
CHANGED
@@ -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
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[
|
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
|
-
|
462
|
-
|
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
|
}
|