mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-29 02:46:25 +02:00
feat: add Zero queries for all 6 synced tables
Define named queries matching each Electric hook's data needs: - notifications.byUser (use-inbox) - documents.bySpace (use-documents, use-documents-processing) - connectors.bySpace (use-connectors-electric) - messages.byThread (use-messages-electric) - comments.byThread (use-comments-electric) - chatSession.byThread (use-chat-session-state) Also moves schema files from zero/tables/ to zero/schema/ for consistent modular folder structure.
This commit is contained in:
parent
af2bd744fb
commit
da8f90bfe2
9 changed files with 75 additions and 4 deletions
41
surfsense_web/zero/schema/index.ts
Normal file
41
surfsense_web/zero/schema/index.ts
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import { createSchema, createBuilder, relationships } from "@rocicorp/zero";
|
||||
import { chatCommentTable, chatSessionStateTable, newChatMessageTable } from "./chat";
|
||||
import { documentTable, searchSourceConnectorTable } from "./documents";
|
||||
import { notificationTable } from "./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