mirror of
https://github.com/outline/outline.git
synced 2026-01-02 00:59:53 -06:00
63 lines
1.2 KiB
TypeScript
63 lines
1.2 KiB
TypeScript
import {
|
|
BelongsTo,
|
|
Column,
|
|
Default,
|
|
ForeignKey,
|
|
IsIn,
|
|
Table,
|
|
DataType,
|
|
Scopes,
|
|
} from "sequelize-typescript";
|
|
import { CollectionPermission } from "@shared/types";
|
|
import Collection from "./Collection";
|
|
import Group from "./Group";
|
|
import User from "./User";
|
|
import Model from "./base/Model";
|
|
import Fix from "./decorators/Fix";
|
|
|
|
@Scopes(() => ({
|
|
withGroup: {
|
|
include: [
|
|
{
|
|
association: "group",
|
|
},
|
|
],
|
|
},
|
|
withCollection: {
|
|
include: [
|
|
{
|
|
association: "collection",
|
|
},
|
|
],
|
|
},
|
|
}))
|
|
@Table({ tableName: "collection_groups", modelName: "collection_group" })
|
|
@Fix
|
|
class CollectionGroup extends Model {
|
|
@Default(CollectionPermission.ReadWrite)
|
|
@IsIn([Object.values(CollectionPermission)])
|
|
@Column(DataType.STRING)
|
|
permission: CollectionPermission;
|
|
|
|
// associations
|
|
|
|
@BelongsTo(() => Collection, "collectionId")
|
|
collection: Collection;
|
|
|
|
@ForeignKey(() => Collection)
|
|
@Column(DataType.UUID)
|
|
collectionId: string;
|
|
|
|
@BelongsTo(() => Group, "groupId")
|
|
group: Group;
|
|
|
|
@ForeignKey(() => Group)
|
|
@Column(DataType.UUID)
|
|
groupId: string;
|
|
|
|
@BelongsTo(() => User, "createdById")
|
|
createdBy: User;
|
|
}
|
|
|
|
export default CollectionGroup;
|