forked from clipboard-history-io/mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstant.schema.ts
More file actions
38 lines (35 loc) · 1.04 KB
/
instant.schema.ts
File metadata and controls
38 lines (35 loc) · 1.04 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
import { i } from "@instantdb/core";
const _schema = i.schema({
entities: {
$users: i.entity({
email: i.string().unique().indexed(),
}),
subscriptions: i.entity({
email: i.string().unique().indexed(),
}),
entries: i.entity({
emailContentHash: i.string().unique().indexed(),
createdAt: i.number().indexed(),
copiedAt: i.number().optional(),
content: i.string(),
isFavorited: i.boolean().optional(),
tags: i.string().optional(),
}),
},
links: {
subscriptionUser: {
forward: { on: "subscriptions", has: "one", label: "$user" },
reverse: { on: "$users", has: "one", label: "subscription" },
},
entriesUser: {
forward: { on: "entries", has: "one", label: "$user" },
reverse: { on: "$users", has: "many", label: "entries" },
},
},
});
// This helps Typescript display better intellisense
type _AppSchema = typeof _schema;
interface AppSchema extends _AppSchema {}
const schema: AppSchema = _schema;
export type { AppSchema };
export default schema;