@apibara/plugin-mongo 2.1.0-beta.15 → 2.1.0-beta.17

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/dist/index.cjs CHANGED
@@ -59,22 +59,22 @@ class MongoStorageError extends Error {
59
59
  }
60
60
  async function withTransaction(client, cb) {
61
61
  return await client.withSession(async (session) => {
62
- return await session.withTransaction(async (session2) => {
63
- return await cb(session2);
64
- });
62
+ return await session.withTransaction(
63
+ async (session2) => {
64
+ return await cb(session2);
65
+ },
66
+ {
67
+ retryWrites: false
68
+ }
69
+ );
65
70
  });
66
71
  }
67
72
 
68
73
  const checkpointCollectionName = "checkpoints";
69
74
  const filterCollectionName = "filters";
70
75
  async function initializePersistentState(db, session) {
71
- const checkpoint = await db.createCollection(
72
- checkpointCollectionName,
73
- { session }
74
- );
75
- const filter = await db.createCollection(filterCollectionName, {
76
- session
77
- });
76
+ const checkpoint = db.collection(checkpointCollectionName);
77
+ const filter = db.collection(filterCollectionName);
78
78
  await checkpoint.createIndex({ id: 1 }, { session });
79
79
  await filter.createIndex({ id: 1, fromBlock: 1 }, { session });
80
80
  }
package/dist/index.mjs CHANGED
@@ -57,22 +57,22 @@ class MongoStorageError extends Error {
57
57
  }
58
58
  async function withTransaction(client, cb) {
59
59
  return await client.withSession(async (session) => {
60
- return await session.withTransaction(async (session2) => {
61
- return await cb(session2);
62
- });
60
+ return await session.withTransaction(
61
+ async (session2) => {
62
+ return await cb(session2);
63
+ },
64
+ {
65
+ retryWrites: false
66
+ }
67
+ );
63
68
  });
64
69
  }
65
70
 
66
71
  const checkpointCollectionName = "checkpoints";
67
72
  const filterCollectionName = "filters";
68
73
  async function initializePersistentState(db, session) {
69
- const checkpoint = await db.createCollection(
70
- checkpointCollectionName,
71
- { session }
72
- );
73
- const filter = await db.createCollection(filterCollectionName, {
74
- session
75
- });
74
+ const checkpoint = db.collection(checkpointCollectionName);
75
+ const filter = db.collection(filterCollectionName);
76
76
  await checkpoint.createIndex({ id: 1 }, { session });
77
77
  await filter.createIndex({ id: 1, fromBlock: 1 }, { session });
78
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apibara/plugin-mongo",
3
- "version": "2.1.0-beta.15",
3
+ "version": "2.1.0-beta.17",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -35,7 +35,7 @@
35
35
  "mongodb": "^6.12.0"
36
36
  },
37
37
  "dependencies": {
38
- "@apibara/indexer": "2.1.0-beta.15",
39
- "@apibara/protocol": "2.1.0-beta.15"
38
+ "@apibara/indexer": "2.1.0-beta.17",
39
+ "@apibara/protocol": "2.1.0-beta.17"
40
40
  }
41
41
  }
@@ -22,13 +22,8 @@ export async function initializePersistentState(
22
22
  db: Db,
23
23
  session: ClientSession,
24
24
  ) {
25
- const checkpoint = await db.createCollection<CheckpointSchema>(
26
- checkpointCollectionName,
27
- { session },
28
- );
29
- const filter = await db.createCollection<FilterSchema>(filterCollectionName, {
30
- session,
31
- });
25
+ const checkpoint = db.collection<CheckpointSchema>(checkpointCollectionName);
26
+ const filter = db.collection<FilterSchema>(filterCollectionName);
32
27
 
33
28
  await checkpoint.createIndex({ id: 1 }, { session });
34
29
  await filter.createIndex({ id: 1, fromBlock: 1 }, { session });
package/src/utils.ts CHANGED
@@ -12,8 +12,13 @@ export async function withTransaction<T>(
12
12
  cb: (session: ClientSession) => Promise<T>,
13
13
  ) {
14
14
  return await client.withSession(async (session) => {
15
- return await session.withTransaction(async (session) => {
16
- return await cb(session);
17
- });
15
+ return await session.withTransaction(
16
+ async (session) => {
17
+ return await cb(session);
18
+ },
19
+ {
20
+ retryWrites: false,
21
+ },
22
+ );
18
23
  });
19
24
  }