CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/util/db-schema/collaborators.ts
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { Table } from "./types";
7
8
Table({
9
name: "collaborators",
10
fields: {
11
account_id: true,
12
first_name: true,
13
last_name: true,
14
name: true,
15
last_active: true,
16
profile: true,
17
},
18
rules: {
19
primary_key: "account_id",
20
db_standby: "unsafe",
21
anonymous: false,
22
virtual: "accounts",
23
user_query: {
24
get: {
25
pg_where: [
26
{
27
"account_id = ANY(SELECT DISTINCT jsonb_object_keys(users)::UUID FROM projects WHERE users ? $::TEXT)":
28
"account_id",
29
},
30
],
31
pg_changefeed: "collaborators",
32
fields: {
33
account_id: null,
34
first_name: "",
35
last_name: "",
36
name: "",
37
last_active: null,
38
profile: null,
39
},
40
},
41
},
42
},
43
});
44
45
// This table does NOT support changefeeds.
46
Table({
47
name: "collaborators_one_project",
48
fields: {
49
account_id: true,
50
project_id: true,
51
first_name: true,
52
last_name: true,
53
name: true,
54
last_active: true,
55
profile: true,
56
},
57
rules: {
58
primary_key: "account_id",
59
db_standby: "unsafe",
60
anonymous: false,
61
virtual: "accounts",
62
user_query: {
63
get: {
64
pg_where: [
65
{
66
"account_id = ANY(SELECT DISTINCT jsonb_object_keys(users)::UUID FROM projects WHERE project_id = $::UUID)":
67
"project_id",
68
},
69
],
70
remove_from_query: [
71
"project_id",
72
] /* this is only used for the pg_where and removed from the actual query */,
73
fields: {
74
account_id: null,
75
project_id: null,
76
first_name: "",
77
last_name: "",
78
name: "",
79
last_active: null,
80
profile: null,
81
},
82
},
83
},
84
},
85
});
86
87