@powersync/service-module-mongodb-storage 0.10.4 → 0.11.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 +32 -0
- package/dist/storage/implementation/MongoBucketBatch.d.ts +20 -1
- package/dist/storage/implementation/MongoBucketBatch.js +59 -3
- package/dist/storage/implementation/MongoBucketBatch.js.map +1 -1
- package/dist/storage/implementation/MongoParameterCompactor.d.ts +17 -0
- package/dist/storage/implementation/MongoParameterCompactor.js +92 -0
- package/dist/storage/implementation/MongoParameterCompactor.js.map +1 -0
- package/dist/storage/implementation/MongoSyncBucketStorage.d.ts +12 -4
- package/dist/storage/implementation/MongoSyncBucketStorage.js +142 -105
- package/dist/storage/implementation/MongoSyncBucketStorage.js.map +1 -1
- package/dist/storage/implementation/models.d.ts +6 -0
- package/dist/storage/implementation/util.d.ts +1 -0
- package/dist/storage/implementation/util.js +13 -0
- package/dist/storage/implementation/util.js.map +1 -1
- package/package.json +6 -6
- package/src/storage/implementation/MongoBucketBatch.ts +74 -2
- package/src/storage/implementation/MongoParameterCompactor.ts +105 -0
- package/src/storage/implementation/MongoSyncBucketStorage.ts +157 -148
- package/src/storage/implementation/models.ts +6 -0
- package/src/storage/implementation/util.ts +13 -0
- package/test/src/storage_compacting.test.ts +2 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -118,9 +118,15 @@ export interface SyncRuleDocument {
|
|
|
118
118
|
snapshot_done: boolean;
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
|
+
* This is now used for "resumeLsn".
|
|
122
|
+
*
|
|
121
123
|
* If snapshot_done = false, this may be the lsn at which we started the snapshot.
|
|
122
124
|
*
|
|
123
125
|
* This can be used for resuming the snapshot after a restart.
|
|
126
|
+
*
|
|
127
|
+
* If snapshot_done is true, this is treated as the point to restart replication from.
|
|
128
|
+
*
|
|
129
|
+
* More specifically, we resume replication from max(snapshot_lsn, last_checkpoint_lsn).
|
|
124
130
|
*/
|
|
125
131
|
snapshot_lsn: string | undefined;
|
|
126
132
|
|
|
@@ -7,6 +7,7 @@ import { storage, utils } from '@powersync/service-core';
|
|
|
7
7
|
|
|
8
8
|
import { PowerSyncMongo } from './db.js';
|
|
9
9
|
import { BucketDataDocument } from './models.js';
|
|
10
|
+
import { ServiceAssertionError } from '@powersync/lib-services-framework';
|
|
10
11
|
|
|
11
12
|
export function idPrefixFilter<T>(prefix: Partial<T>, rest: (keyof T)[]): mongo.Condition<T> {
|
|
12
13
|
let filter = {
|
|
@@ -117,3 +118,15 @@ export const connectMongoForTests = (url: string, isCI: boolean) => {
|
|
|
117
118
|
});
|
|
118
119
|
return new PowerSyncMongo(client);
|
|
119
120
|
};
|
|
121
|
+
|
|
122
|
+
export function setSessionSnapshotTime(session: mongo.ClientSession, time: bson.Timestamp) {
|
|
123
|
+
// This is a workaround for the lack of direct support for snapshot reads in the MongoDB driver.
|
|
124
|
+
if (!session.snapshotEnabled) {
|
|
125
|
+
throw new ServiceAssertionError(`Session must be a snapshot session`);
|
|
126
|
+
}
|
|
127
|
+
if ((session as any).snapshotTime == null) {
|
|
128
|
+
(session as any).snapshotTime = time;
|
|
129
|
+
} else {
|
|
130
|
+
throw new ServiceAssertionError(`Session snapshotTime is already set`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -3,3 +3,5 @@ import { describe } from 'vitest';
|
|
|
3
3
|
import { INITIALIZED_MONGO_STORAGE_FACTORY } from './util.js';
|
|
4
4
|
|
|
5
5
|
describe('Mongo Sync Bucket Storage Compact', () => register.registerCompactTests(INITIALIZED_MONGO_STORAGE_FACTORY));
|
|
6
|
+
describe('Mongo Sync Parameter Storage Compact', () =>
|
|
7
|
+
register.registerParameterCompactTests(INITIALIZED_MONGO_STORAGE_FACTORY));
|