Love to see this project shaping up, would it be possible to improve its DX for passing the schema to orm?
As of now we are forced to pass tables as rest param:
const db = orm(new Surreal(), user, post, authored);
but wouldn't it be more simple to have them as object instead?
Like:
const db = orm(new Surreal(), {
user,
post,
authored,
});
This could also unlock the ability to define all the tables in a unified place and then import them via alias while keeping full type support:
// database/schema.ts
import { table, t, edge } from "surqlize";
export const user = table("user", {
name: t.string(),
email: t.string(),
});
export const post = table("post", {
title: t.string(),
content: t.string(),
});
export const authored = edge("user", "authored", "post", {
created: t.date(),
role: t.union([t.literal("author"), t.literal("co-author")]),
});
// src/surqlize.ts
import * as schema from '../database/schema.ts'
const db = orm(new Surreal(), schema);
This would greatly benefit rapid reuse of separate orm that might share all or part of the schema
Love to see this project shaping up, would it be possible to improve its DX for passing the schema to
orm?As of now we are forced to pass tables as rest param:
but wouldn't it be more simple to have them as object instead?
Like:
This could also unlock the ability to define all the tables in a unified place and then import them via alias while keeping full type support:
This would greatly benefit rapid reuse of separate
ormthat might share all or part of the schema