feat: initial backend store prototype
Some checks failed
Deploy to GitHub Pages / build_site (push) Failing after 13s
Some checks failed
Deploy to GitHub Pages / build_site (push) Failing after 13s
This commit is contained in:
40
store/src/routes/node/node.schema.ts
Normal file
40
store/src/routes/node/node.schema.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import {
|
||||
customType,
|
||||
integer,
|
||||
json,
|
||||
pgTable,
|
||||
serial,
|
||||
varchar,
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { relations } from "drizzle-orm/relations";
|
||||
import { usersTable } from "../user/user.schema.ts";
|
||||
|
||||
const bytea = customType<{
|
||||
data: ArrayBuffer;
|
||||
default: false;
|
||||
}>({
|
||||
dataType() {
|
||||
return "bytea";
|
||||
},
|
||||
});
|
||||
|
||||
export const nodeTable = pgTable("nodes", {
|
||||
id: serial().primaryKey(),
|
||||
userId: varchar().notNull(),
|
||||
systemId: varchar().notNull(),
|
||||
nodeId: varchar().notNull(),
|
||||
content: bytea().notNull(),
|
||||
definition: json().notNull(),
|
||||
previous: integer(),
|
||||
});
|
||||
|
||||
export const nodeRelations = relations(nodeTable, ({ one }) => ({
|
||||
userId: one(usersTable, {
|
||||
fields: [nodeTable.userId],
|
||||
references: [usersTable.id],
|
||||
}),
|
||||
previous: one(nodeTable, {
|
||||
fields: [nodeTable.previous],
|
||||
references: [nodeTable.id],
|
||||
}),
|
||||
}));
|
||||
Reference in New Issue
Block a user