mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-27 17:56:25 +02:00
feat: add Zero schema with 6 table definitions and relationships
- Create zero/tables/inbox.ts (notifications) - Create zero/tables/documents.ts (documents, search_source_connectors) - Create zero/tables/chat.ts (new_chat_messages, chat_comments, chat_session_state) - Create zero/schema.ts (combines tables, defines relationships, exports zql) - Consolidate Zero type augmentations into types/zero.d.ts
This commit is contained in:
parent
8298aad2d7
commit
af2bd744fb
5 changed files with 125 additions and 0 deletions
41
surfsense_web/zero/schema.ts
Normal file
41
surfsense_web/zero/schema.ts
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import { createSchema, createBuilder, relationships } from "@rocicorp/zero";
|
||||
import { chatCommentTable, chatSessionStateTable, newChatMessageTable } from "./tables/chat";
|
||||
import { documentTable, searchSourceConnectorTable } from "./tables/documents";
|
||||
import { notificationTable } from "./tables/inbox";
|
||||
|
||||
const chatCommentRelationships = relationships(chatCommentTable, ({ one }) => ({
|
||||
message: one({
|
||||
sourceField: ["messageId"],
|
||||
destSchema: newChatMessageTable,
|
||||
destField: ["id"],
|
||||
}),
|
||||
parent: one({
|
||||
sourceField: ["parentId"],
|
||||
destSchema: chatCommentTable,
|
||||
destField: ["id"],
|
||||
}),
|
||||
}));
|
||||
|
||||
const newChatMessageRelationships = relationships(newChatMessageTable, ({ many }) => ({
|
||||
comments: many({
|
||||
sourceField: ["id"],
|
||||
destSchema: chatCommentTable,
|
||||
destField: ["messageId"],
|
||||
}),
|
||||
}));
|
||||
|
||||
export const schema = createSchema({
|
||||
tables: [
|
||||
notificationTable,
|
||||
documentTable,
|
||||
searchSourceConnectorTable,
|
||||
newChatMessageTable,
|
||||
chatCommentTable,
|
||||
chatSessionStateTable,
|
||||
],
|
||||
relationships: [chatCommentRelationships, newChatMessageRelationships],
|
||||
});
|
||||
|
||||
export type Schema = typeof schema;
|
||||
|
||||
export const zql = createBuilder(schema);
|
||||
Loading…
Add table
Add a link
Reference in a new issue