chore: Docs, define additional client-side relations
This commit is contained in:
@@ -1,12 +1,26 @@
|
||||
import { observable } from "mobx";
|
||||
import Collection from "./Collection";
|
||||
import Document from "./Document";
|
||||
import Model from "./base/Model";
|
||||
import Field from "./decorators/Field";
|
||||
import Relation from "./decorators/Relation";
|
||||
|
||||
class Pin extends Model {
|
||||
id: string;
|
||||
/** The collection ID that the document is pinned to. If empty the document is pinned to home. */
|
||||
collectionId: string;
|
||||
|
||||
/** The collection that the document is pinned to. If empty the document is pinned to home. */
|
||||
@Relation(() => Collection, { onDelete: "cascade" })
|
||||
collection?: Collection;
|
||||
|
||||
/** The document ID that is pinned. */
|
||||
documentId: string;
|
||||
|
||||
/** The document that is pinned. */
|
||||
@Relation(() => Document, { onDelete: "cascade" })
|
||||
document: Document;
|
||||
|
||||
/** The sort order of the pin on screen. */
|
||||
@observable
|
||||
@Field
|
||||
index: string;
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
import { computed } from "mobx";
|
||||
import { isRTL } from "@shared/utils/rtl";
|
||||
import Document from "./Document";
|
||||
import User from "./User";
|
||||
import Model from "./base/Model";
|
||||
import Relation from "./decorators/Relation";
|
||||
|
||||
class Revision extends Model {
|
||||
id: string;
|
||||
|
||||
/** The document ID that the revision is related to */
|
||||
documentId: string;
|
||||
|
||||
/** The document that the revision is related to */
|
||||
@Relation(() => Document, { onDelete: "cascade" })
|
||||
document: Document;
|
||||
|
||||
/** The document title when the revision was created */
|
||||
title: string;
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
import { observable } from "mobx";
|
||||
import Document from "./Document";
|
||||
import User from "./User";
|
||||
import Model from "./base/Model";
|
||||
import Field from "./decorators/Field";
|
||||
import Relation from "./decorators/Relation";
|
||||
|
||||
class Share extends Model {
|
||||
@Field
|
||||
@observable
|
||||
id: string;
|
||||
|
||||
@Field
|
||||
@observable
|
||||
published: boolean;
|
||||
@@ -16,10 +14,15 @@ class Share extends Model {
|
||||
@observable
|
||||
includeChildDocuments: boolean;
|
||||
|
||||
/** The document ID that is shared. */
|
||||
@Field
|
||||
@observable
|
||||
documentId: string;
|
||||
|
||||
/** The document that is shared. */
|
||||
@Relation(() => Document, { onDelete: "cascade" })
|
||||
document: Document;
|
||||
|
||||
@Field
|
||||
@observable
|
||||
urlId: string;
|
||||
@@ -36,6 +39,8 @@ class Share extends Model {
|
||||
@observable
|
||||
url: string;
|
||||
|
||||
/** The user that shared the document. */
|
||||
@Relation(() => User, { onDelete: "null" })
|
||||
createdBy: User;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +1,44 @@
|
||||
import { observable } from "mobx";
|
||||
import type StarsStore from "~/stores/StarsStore";
|
||||
import Collection from "./Collection";
|
||||
import Document from "./Document";
|
||||
import Model from "./base/Model";
|
||||
import Field from "./decorators/Field";
|
||||
import Relation from "./decorators/Relation";
|
||||
|
||||
class Star extends Model {
|
||||
id: string;
|
||||
|
||||
/** The sort order of the star */
|
||||
@Field
|
||||
@observable
|
||||
index: string;
|
||||
|
||||
documentId: string;
|
||||
/** The document ID that is starred. */
|
||||
documentId?: string;
|
||||
|
||||
/** The document that is starred. */
|
||||
@Relation(() => Document, { onDelete: "cascade" })
|
||||
document?: Document;
|
||||
|
||||
/** The collection ID that is starred. */
|
||||
collectionId: string;
|
||||
|
||||
/** The collection that is starred. */
|
||||
@Relation(() => Collection, { onDelete: "cascade" })
|
||||
collection: Collection;
|
||||
|
||||
store: StarsStore;
|
||||
|
||||
/**
|
||||
* Returns the next star in the list, or undefined if this is the last star.
|
||||
*/
|
||||
next(): Star | undefined {
|
||||
const index = this.store.orderedData.indexOf(this);
|
||||
return this.store.orderedData[index + 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the previous star in the list, or undefined if this is the first star.
|
||||
*/
|
||||
previous(): Star | undefined {
|
||||
const index = this.store.orderedData.indexOf(this);
|
||||
return this.store.orderedData[index + 1];
|
||||
|
||||
@@ -1,22 +1,28 @@
|
||||
import { observable } from "mobx";
|
||||
import Document from "./Document";
|
||||
import User from "./User";
|
||||
import Model from "./base/Model";
|
||||
import Field from "./decorators/Field";
|
||||
import Relation from "./decorators/Relation";
|
||||
|
||||
/**
|
||||
* A subscription represents a request for a user to receive notifications for
|
||||
* a document.
|
||||
* A subscription represents a request for a user to receive notifications for a document.
|
||||
*/
|
||||
class Subscription extends Model {
|
||||
@Field
|
||||
@observable
|
||||
id: string;
|
||||
|
||||
/** The user subscribing */
|
||||
/** The user ID subscribing */
|
||||
userId: string;
|
||||
|
||||
/** The document being subscribed to */
|
||||
/** The user subscribing */
|
||||
@Relation(() => User, { onDelete: "cascade" })
|
||||
user?: User;
|
||||
|
||||
/** The document ID being subscribed to */
|
||||
documentId: string;
|
||||
|
||||
/** The document being subscribed to */
|
||||
@Relation(() => Document, { onDelete: "cascade" })
|
||||
document?: Document;
|
||||
|
||||
/** The event being subscribed to */
|
||||
@Field
|
||||
@observable
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { action, observable } from "mobx";
|
||||
import User from "./User";
|
||||
import Model from "./base/Model";
|
||||
import Relation from "./decorators/Relation";
|
||||
|
||||
class View extends Model {
|
||||
id: string;
|
||||
@@ -15,6 +16,7 @@ class View extends Model {
|
||||
@observable
|
||||
count: number;
|
||||
|
||||
@Relation(() => User)
|
||||
user: User;
|
||||
|
||||
@action
|
||||
|
||||
Reference in New Issue
Block a user