cloudflare / wildebeest

Wildebeest is an ActivityPub and Mastodon-compatible server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Refactoring to easily support other databases

haikyuu opened this issue · comments

First, thanks for open sourcing this. This is a great addition to the open-source world.

D1 and SQLite are great. But there are so many other choices for dbs.

What do you think about abstracting the db part just a bit to allow people who fork this project to swap it transparently?

import edgedbAdapter from './edgedbAdapter.js'

const config = { dbAdapter: edgedbAdapter }

The adapter would have a ts spec.

The db functions are already typed, so it wouldn't be hard to do the refactoring.

And in order to create an adapter, a user has to implement all the query functions in the adapter file.

I believe this will immensely help adoption of this project and create a vibrant ecosystem around it. Especially if db providers provide an adapter (supabase, mongo, prisma, edgedb ...).

Another use case is people who want to integrate this project into their existing system and database. I think you get the point :)

Since it’s outside of wildebeest’s core directive as a Cloudflare-native app, I think the only way to know whether this would be approved is to make a small PR. Then the tentative changes can be discussed in the context of a proof-of-concept that clearly demonstrates the trade-offs.

The code has been refactored to allow other databases, based on D1's API interface. I'm adding neon.tech (postgresql) as another supported database.

Thanks @xtuc this is amazing 🙌