-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstant.perms.ts
More file actions
48 lines (46 loc) · 1.28 KB
/
instant.perms.ts
File metadata and controls
48 lines (46 loc) · 1.28 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
import type { InstantRules } from "@instantdb/react";
/**
* Push with: npx instant-cli@latest push perms
* Adjust attrs.allow when your schema is stable.
*/
const rules = {
attrs: {
allow: {
$default: "false",
create: "true",
},
},
$files: {
allow: {
view: "true",
create: "auth.id != null && data.path.startsWith(auth.id + '/')",
delete: "auth.id != null && data.path.startsWith(auth.id + '/')",
update: "auth.id != null && data.path.startsWith(auth.id + '/')",
},
},
profiles: {
allow: {
view: "true",
create: "auth.id != null && auth.id in data.ref('$user.id')",
update: "auth.id != null && auth.id in data.ref('$user.id')",
delete: "false",
},
},
memes: {
allow: {
view: "true",
create: "auth.id != null && auth.id in data.ref('author.$user.id')",
update: "auth.id != null && auth.id in data.ref('author.$user.id')",
delete: "auth.id != null && auth.id in data.ref('author.$user.id')",
},
},
upvotes: {
allow: {
view: "true",
create: "auth.id != null && auth.id in data.ref('voter.$user.id')",
delete: "auth.id != null && auth.id in data.ref('voter.$user.id')",
update: "false",
},
},
} satisfies InstantRules;
export default rules;