-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathrql-data-models.ts
83 lines (76 loc) · 1.82 KB
/
rql-data-models.ts
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import Realm, { BSON, ObjectSchema } from "realm";
// Models for embedded objects & dot notation queries
export class Address extends Realm.Object<Address> {
name!: string;
street!: string;
zipcode!: number;
static schema: ObjectSchema = {
name: "Address",
embedded: true,
properties: {
name: "string",
street: "string",
zipcode: "int",
},
};
}
export class Office extends Realm.Object<Office> {
name!: string;
address!: Address;
static schema: ObjectSchema = {
name: "Office",
properties: {
name: "string",
address: "Address",
},
};
}
// :snippet-start: rql-data-models
export class Item extends Realm.Object<Item> {
_id!: BSON.ObjectId;
name!: string;
isComplete!: boolean;
assignee?: string;
priority!: number;
progressMinutes?: number;
static schema: ObjectSchema = {
name: "Item",
properties: {
_id: "objectId",
name: { type: "string", indexed: "full-text" },
isComplete: { type: "bool", default: false },
assignee: "string?",
priority: { type: "int", default: 0 },
progressMinutes: { type: "int", default: 0 },
projects: {
type: "linkingObjects",
objectType: "Project",
property: "items",
},
},
primaryKey: "_id",
};
}
export class Project extends Realm.Object<Project> {
_id!: BSON.ObjectId;
name!: string;
items!: Realm.List<Item>;
quota?: number;
comments?: Realm.Dictionary<string>;
projectLocation?: Office;
additionalInfo!: Realm.Mixed;
static schema: ObjectSchema = {
name: "Project",
properties: {
_id: "objectId",
name: "string",
items: "Item[]",
quota: "int?",
comments: "string?{}",
projectLocation: "Office?",
additionalInfo: "mixed",
},
primaryKey: "_id",
};
}
// :snippet-end: