hallgren / eventsourcing

Event Sourcing in Go
Mozilla Public License 2.0
186 stars 20 forks source link

Support for Pocketbase #115

Closed eugeis closed 1 week ago

eugeis commented 3 weeks ago

Hello,

thanks for great design.

I am using pocketbase and looking for an eventsourcing framework to use with it.

Ehat do you think about addidng support for Pocketbase, to use it as base for event and projection stores and to have REST endpoints for events etc.

hallgren commented 3 weeks ago

Hi Eugen and thanks for your interest.

It should be somewhat straight forward to create a new event store for pocketbase. I have a collection that is supported sql/bbolt/esdb and there is one external for dynamo db: https://github.com/fd1az/dynamo-es.

I'm willing to help you if you want to create an event store for pockebase that you support and maintain in your GitHub account.

BR Morgan

hallgren commented 3 weeks ago

I had a look at https://pocketbase.io/docs/go-database/ and it seams close to the sql event store as there is a sql database behind pocketbase.

eugeis commented 3 weeks ago

Hi Morgan,

thanks, I will try out to implement it, based on your sql event store.

hallgren commented 2 weeks ago

Hi,

I had a look into pockebase and I think it will work out of the box together with the sql event store.

import (
    "github.com/pocketbase/dbx"
    _ "github.com/go-sql-driver/mysql"
        "github.com/hallgren/eventsourcing/eventstore/sql"
)

db, _ := dbx.Open("mysql", "user:pass@/example")

sqlDB := db.DB() // returns the sql.DB struct from the database/sql package. The same struct that is used in the sql event store.

sqlES := sql.Open(sqlDB) // You now should have an sql event store that you can read and write events to.

I have no idea if bypassing the pockebase DB struct will affect features in pocketbase.

hallgren commented 1 week ago

@eugeis I close this issue. Please reach out if you have any more questions or if it just works :)