@powersync/service-module-mongodb-storage 0.0.0-dev-20250310190630 → 0.0.0-dev-20250312090341
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 +6 -8
- package/dist/migrations/db/migrations/1741697235857-bucket-state-index.d.ts +3 -0
- package/dist/migrations/db/migrations/1741697235857-bucket-state-index.js +28 -0
- package/dist/migrations/db/migrations/1741697235857-bucket-state-index.js.map +1 -0
- package/dist/storage/implementation/MongoBucketBatch.d.ts +4 -0
- package/dist/storage/implementation/MongoBucketBatch.js +1 -1
- package/dist/storage/implementation/MongoBucketBatch.js.map +1 -1
- package/dist/storage/implementation/MongoCompactor.js +14 -1
- package/dist/storage/implementation/MongoCompactor.js.map +1 -1
- package/dist/storage/implementation/MongoSyncBucketStorage.d.ts +6 -0
- package/dist/storage/implementation/MongoSyncBucketStorage.js +100 -8
- package/dist/storage/implementation/MongoSyncBucketStorage.js.map +1 -1
- package/dist/storage/implementation/PersistedBatch.d.ts +8 -0
- package/dist/storage/implementation/PersistedBatch.js +57 -2
- package/dist/storage/implementation/PersistedBatch.js.map +1 -1
- package/dist/storage/implementation/db.d.ts +2 -1
- package/dist/storage/implementation/db.js +3 -0
- package/dist/storage/implementation/db.js.map +1 -1
- package/dist/storage/implementation/models.d.ts +8 -0
- package/package.json +5 -5
- package/src/migrations/db/migrations/1741697235857-bucket-state-index.ts +40 -0
- package/src/storage/implementation/MongoBucketBatch.ts +1 -1
- package/src/storage/implementation/MongoCompactor.ts +19 -1
- package/src/storage/implementation/MongoSyncBucketStorage.ts +128 -10
- package/src/storage/implementation/PersistedBatch.ts +66 -2
- package/src/storage/implementation/db.ts +4 -0
- package/src/storage/implementation/models.ts +9 -0
- package/test/src/setup.ts +3 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -6,6 +6,7 @@ import { MongoStorageConfig } from '../../types/types.js';
|
|
|
6
6
|
import {
|
|
7
7
|
BucketDataDocument,
|
|
8
8
|
BucketParameterDocument,
|
|
9
|
+
BucketStateDocument,
|
|
9
10
|
CurrentDataDocument,
|
|
10
11
|
CustomWriteCheckpointDocument,
|
|
11
12
|
IdSequenceDocument,
|
|
@@ -33,6 +34,7 @@ export class PowerSyncMongo {
|
|
|
33
34
|
readonly write_checkpoints: mongo.Collection<WriteCheckpointDocument>;
|
|
34
35
|
readonly instance: mongo.Collection<InstanceDocument>;
|
|
35
36
|
readonly locks: mongo.Collection<lib_mongo.locks.Lock>;
|
|
37
|
+
readonly bucket_state: mongo.Collection<BucketStateDocument>;
|
|
36
38
|
|
|
37
39
|
readonly client: mongo.MongoClient;
|
|
38
40
|
readonly db: mongo.Db;
|
|
@@ -55,6 +57,7 @@ export class PowerSyncMongo {
|
|
|
55
57
|
this.write_checkpoints = db.collection('write_checkpoints');
|
|
56
58
|
this.instance = db.collection('instance');
|
|
57
59
|
this.locks = this.db.collection('locks');
|
|
60
|
+
this.bucket_state = this.db.collection('bucket_state');
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
/**
|
|
@@ -70,6 +73,7 @@ export class PowerSyncMongo {
|
|
|
70
73
|
await this.write_checkpoints.deleteMany({});
|
|
71
74
|
await this.instance.deleteOne({});
|
|
72
75
|
await this.locks.deleteMany({});
|
|
76
|
+
await this.bucket_state.deleteMany({});
|
|
73
77
|
}
|
|
74
78
|
|
|
75
79
|
/**
|
|
@@ -75,6 +75,15 @@ export interface SourceTableDocument {
|
|
|
75
75
|
snapshot_done: boolean | undefined;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
export interface BucketStateDocument {
|
|
79
|
+
_id: {
|
|
80
|
+
g: number;
|
|
81
|
+
b: string;
|
|
82
|
+
};
|
|
83
|
+
last_op: bigint;
|
|
84
|
+
op_count: number;
|
|
85
|
+
}
|
|
86
|
+
|
|
78
87
|
export interface IdSequenceDocument {
|
|
79
88
|
_id: string;
|
|
80
89
|
op_id: bigint;
|
package/test/src/setup.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { container } from '@powersync/lib-services-framework';
|
|
2
|
+
import { test_utils } from '@powersync/service-core-tests';
|
|
2
3
|
import { beforeAll, beforeEach } from 'vitest';
|
|
3
|
-
import { METRICS_HELPER } from '@powersync/service-core-tests';
|
|
4
4
|
|
|
5
5
|
beforeAll(async () => {
|
|
6
6
|
// Executes for every test file
|
|
7
7
|
container.registerDefaults();
|
|
8
|
+
await test_utils.initMetrics();
|
|
8
9
|
});
|
|
9
10
|
|
|
10
11
|
beforeEach(async () => {
|
|
11
|
-
|
|
12
|
+
await test_utils.resetMetrics();
|
|
12
13
|
});
|