forked from dqnamo/chaterface
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstant.schema.ts
More file actions
69 lines (65 loc) · 1.96 KB
/
instant.schema.ts
File metadata and controls
69 lines (65 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Docs: https://www.instantdb.com/docs/modeling-data
import { i } from "@instantdb/react";
const _schema = i.schema({
entities: {
$files: i.entity({
path: i.string().unique().indexed(),
url: i.any(),
}),
$users: i.entity({
email: i.string().unique().indexed(),
}),
userProfiles: i.entity({
credits: i.number().optional(),
theme: i.string().optional(),
hasPurchasedCredits: i.boolean().optional(),
}),
conversations: i.entity({
name: i.string(),
createdAt: i.date().indexed(),
sessionId: i.string().optional(),
}),
messages: i.entity({
role: i.string(),
content: i.string(),
createdAt: i.date(),
model: i.string(),
creditsConsumed: i.number().optional(),
}),
personas: i.entity({
name: i.string(),
createdAt: i.date(),
prompt: i.string(),
description: i.string().optional(),
}),
},
links: {
conversationMessages: {
forward: { on: "messages", has: "one", label: "conversation" },
reverse: { on: "conversations", has: "many", label: "messages" }
},
conversationUser: {
forward: { on: "conversations", has: "one", label: "user" },
reverse: { on: "$users", has: "many", label: "conversations" }
},
userProfile: {
forward: { on: "userProfiles", has: "one", label: "user" },
reverse: { on: "$users", has: "one", label: "profile" },
},
userPersonas: {
forward: { on: "personas", has: "one", label: "user" },
reverse: { on: "$users", has: "many", label: "personas" }
},
messagePersona: {
forward: { on: "messages", has: "one", label: "persona" },
reverse: { on: "personas", has: "many", label: "messages" }
},
},
rooms: {},
});
// This helps Typescript display nicer intellisense
type _AppSchema = typeof _schema;
interface AppSchema extends _AppSchema {}
const schema: AppSchema = _schema;
export type { AppSchema };
export default schema;