0.15.0
🚀 What's New
1. Refactored PostgreSQL event store to benefit from the latest Pongo and Dumbo improvements
Now, it's possible to inject ambient connections and use non-pooled event stores in the same way as in Pongo.
To run a non-pooled setup (e.g. for Cloudflare Hyperdrive or Supabase Supavisor) you need to do the following:
const eventStore = getPostgreSQLEventStore(connectionString, {
projections: [shoppingCartShortInfoProjection, customProjection],
connectionOptions: { pooled: false },
});
Now you can also use custom projection as:
import { sql } from '@event-driven-io/dumbo';
import { postgreSQLInlineProjection, sql } from '@event-driven-io/emmett-postgresql';
const customProjection = postgreSQLInlineProjection<ShoppingCartEvent>({
name: 'customProjection',
canHandle: ['ProductItemAdded'],
handle: (events, { execute }) =>
execute.batchCommand(
events.map(({ shoppingCartId, productId, quantity }) =>
sql('INSERT INTO product_items VALUES(%s, %L, %L)', productId, quantity));
)
),
});
by @oskardudycz in #101
2. Added raw sql projections to support raw SQL handling
Generalised also projection definition.
Made postgreSQLProjection
and inlineProjection
obsolete, use postgreSQLProjection
and postgreSQLInlineProjection
instead.
Now you can use the new projections raw projection as:
import { sql } from '@event-driven-io/dumbo';
import { postgreSQLRawSQLProjection } from '@event-driven-io/emmett-postgresql';
const rawSQLProjection = postgreSQLRawSQLProjection<ProductItemAdded>({
name: 'customProjection',
canHandle: ['ProductItemAdded'],
handle: (event, context) =>
sql(
'INSERT INTO product_items VALUES(%s, %s, %L)',
event.shoppingCartId, event.productId, event.quantity)
)
});
There's also postgreSQLRawBatchSQLProjection
that handles a batch of events accordingly. Both can be sync or async. You can access and query the database through the context
handler param.
by @oskardudycz in #102
3. Added a basic example of projection handling to PostgreSQL samples.
You can check it here in the source code. by @oskardudycz in 100
Full Changelog: 0.14.1...0.15.0