@acuris/eventstore-postgresql
Advanced tools
Comparing version 1.2.1 to 1.2.2
import * as Pg from "pg"; | ||
import { PgSchemaManager } from "./PgSchemaManager"; | ||
import { EventBatchWriter, EventSource } from "@acuris/eventstore-api"; | ||
import { EventSource } from "@acuris/eventstore-api"; | ||
import { PgEventReader } from "./PgEventReader"; | ||
@@ -8,2 +8,3 @@ import { PgEventStreamReader } from "./PgEventStreamReader"; | ||
import { ConnectionProvider } from "./ConnectionProvider"; | ||
import { PgEventBatchWriter } from "./PgEventBatchWriter"; | ||
export declare function pgAsyncConfigForAWS(region: string, hostname: string, port: number, database: string, username: string): Pg.ClientConfig; | ||
@@ -18,4 +19,4 @@ export declare class PgEventSource implements EventSource { | ||
get streamWriter(): PgEventStreamWriter; | ||
get batchWriter(): EventBatchWriter; | ||
get batchWriter(): PgEventBatchWriter; | ||
close(): Promise<void>; | ||
} |
@@ -5,6 +5,6 @@ "use strict"; | ||
const PgSchemaManager_1 = require("./PgSchemaManager"); | ||
const eventstore_api_1 = require("@acuris/eventstore-api"); | ||
const PgEventReader_1 = require("./PgEventReader"); | ||
const PgEventStreamReader_1 = require("./PgEventStreamReader"); | ||
const PgEventStreamWriter_1 = require("./PgEventStreamWriter"); | ||
const PgEventBatchWriter_1 = require("./PgEventBatchWriter"); | ||
function pgAsyncConfigForAWS(region, hostname, port, database, username) { | ||
@@ -46,3 +46,3 @@ const AWS = require("aws-sdk"); | ||
get batchWriter() { | ||
return new eventstore_api_1.DefaultEventBatchWriter(this.streamWriter); | ||
return new PgEventBatchWriter_1.PgEventBatchWriter(this.provider, this.schema); | ||
} | ||
@@ -49,0 +49,0 @@ close() { |
@@ -13,4 +13,6 @@ "use strict"; | ||
const quotedSchema = conn.escapeIdentifier(this.schema); | ||
let nextExpectedEventNumber = expectedEventNumber; | ||
for (const event of events) { | ||
await conn.query(`SELECT 1 FROM ${quotedSchema}.write_event($1, $2, $3, $4, null, $5)`, [streamId.category, streamId.id, event.type, event.data, expectedEventNumber]); | ||
await conn.query(`SELECT 1 FROM ${quotedSchema}.write_event($1, $2, $3, $4, null, $5)`, [streamId.category, streamId.id, event.type, event.data, nextExpectedEventNumber]); | ||
nextExpectedEventNumber = undefined; | ||
} | ||
@@ -17,0 +19,0 @@ })); |
{ | ||
"name": "@acuris/eventstore-postgresql", | ||
"private": false, | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "Eventstore implementation storing events in Postgresql", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
42171
35
987