#594·colyseus

[Feature] Database access

Author: endelCreated Jun 26, 2023Updated Jan 24, 2025
Labels:rocket: feature:eyes: triage

Context & Description

Databases are such an important piece of any game/application.

Providing a "standard" way to use and consume databases would make it easier to not only re-use and share tiny bits of features between different projects but also provide a building block for database-related features the framework could offer out-of-the-box.

The objective

The objective here is to select a safe module we can build on top of.

Every developer has their favorite SQL builder/ORM (or detests it deeply ), and the one selected is (hopefully?) going to be used for years to come.

This new feature will inevitably spark a number of database-related issues and requests that may only be solvable by the original library we are building upon could fix. (There have been some sustainability issues with big ORM projects like https://github.com/Vincit/objection.js/issues/2335, https://github.com/typeorm/typeorm/issues/3267)

Use cases

  • User authentication
  • Persisting room state between sessions
  • "Async games" where other players don't necessarily need to be online
  • Tournament-style games
  • Leaderboards
  • (...more stuff!)

Proposal

Features I would love to have:

  • ORM-like API
  • Be frictionless during development: provide automatic migration when inserting data into the database (could be disabled in production)

So far I'm leaning towards kysely. I'm curious to hear your thoughts!


(Linked issues: https://github.com/colyseus/colyseus/issues/425, https://github.com/colyseus/colyseus/issues/177)