@colyseus/database
v0.0.13
Published
Colyseus Database Tools
Downloads
42
Readme
@colyseus/database
GitHub Feature Proposal: https://github.com/colyseus/colyseus/issues/594
This is a small layer of abstraction over Kysely
, while also exposing it directly.
(Kysely currently has built-in support for SQLite, PostgreSQL, and MySQL.)
This is not an ORM!
Planned features
- ORM-like API
- Be frictionless during development: provide automatic migration when inserting data into the database (could be disabled in production)
- Create and run migrations from the CLI.
Usage
import { Database, PostgresDialect } from "@colyseus/database";
import pg from "pg";
// schema fields
interface Player {
name: string;
}
const db = new Database<{
// database schema / types
players: Player,
}>({
// database config
dialect: new PostgresDialect({
pool: new pg.Pool({
host: "localhost",
database: "endel",
})
})
});
// collection API
const Player = db.collection("players");
const playerId = await Player.insert({
name: "Rigolo"
});
External Tooling
kysely-codegen
: Generate Kysely type definitions from your database.
Notes:
@alexanderson1993: Prisma-like Migrations and type safety with Kysely
License
MIT