-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGroup.ts
28 lines (20 loc) · 891 Bytes
/
Group.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
import type { Relation } from 'soukai';
import type SolidBelongsToManyRelation from '@/models/relations/SolidBelongsToManyRelation';
import type SolidBelongsToOneRelation from '@/models/relations/SolidBelongsToOneRelation';
import Person from '@/testing/lib/stubs/Person';
import Model from './Group.schema';
export default class Group extends Model {
public creator?: Person;
public members?: Person[];
public relatedCreator!: SolidBelongsToOneRelation<Group, Person, typeof Person>;
public relatedMembers!: SolidBelongsToManyRelation<Group, Person, typeof Person>;
public creatorRelationship(): Relation {
return this
.belongsToOne(Person, 'creatorUrl')
.usingSameDocument(true)
.onDelete('cascade');
}
public membersRelationship(): Relation {
return this.belongsToMany(Person, 'memberUrls');
}
}