Skip to content

0.10.0

Compare
Choose a tag to compare
@oskardudycz oskardudycz released this 07 Aug 10:16
· 248 commits to main since this release

🚀 What's New

Refactored pooling, connection, transaction setup. Most of the work was made in Dumbo to enable future use of other databases or PostgreSQL drivers.

Now Dumbo should be usable even as a standalone package. You can do the following:

import { dumbo, rawSql } from '@event-driven-io/dumbo';

const pool = dumbo({ connectionString });

const result = await pool.execute.query<User>(rawSql('SELECT * from users'));

or with transactions:

import { dumbo, sql } from '@event-driven-io/dumbo';

const userId = 32;
const userName = "[email protected]";
const pool = dumbo({ connectionString });

await pool.withTransaction(async ({ execute }) => {
  await execute.command(sql('INSERT INTO users VALUES(%s, %L)', userId, userName));
  await execute.command(sql('INSERT INTO user_roles VALUES(%s, %L)', userId, 'admin') );
})

You can now also share the connection and transaction between your tool and Pongo, e.g. by doing:

import { dumbo, sql } from '@event-driven-io/dumbo';

const userId = 32;
const userName = "[email protected]";
const pool = dumbo({ connectionString });

await pool.withTransaction(async ({ execute }) => {
  // sharing transaction connection with pongo
  const pongo = pongoClient(connectionString, { connection });
  
  const users = pongo.db().collection<User>('users');
  await users.insertOne({ name: randomUUID() });
  await users.insertOne({ name: randomUUID() });

  // doing also insert outside of pongo
  await execute.command(sql('INSERT INTO user_roles VALUES(%s, %L)', userId, 'admin') );
})

That will be a basis for extended integration between Pongo and Emmett. A new projection type will be easier to add (e.g. for doing custom SQL based on events).

by @oskardudycz in #54

Full Changelog: 0.9.0...0.10.0