aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-03-16 14:24:26 +0100
committerChocobozzz <me@florianbigard.com>2023-03-16 14:24:26 +0100
commit016b887802aebdb1bada121aa2102f0e0f6e0997 (patch)
treea7c1648a12c8fc1a2e40cf34f1b3b1f24efba6f4
parent11c834bdba42f124a172b643b292e45f043b3be9 (diff)
downloadPeerTube-016b887802aebdb1bada121aa2102f0e0f6e0997.tar.gz
PeerTube-016b887802aebdb1bada121aa2102f0e0f6e0997.tar.zst
PeerTube-016b887802aebdb1bada121aa2102f0e0f6e0997.zip
Add custom sequelize model types documentation
-rw-r--r--support/doc/development/server.md8
1 files changed, 8 insertions, 0 deletions
diff --git a/support/doc/development/server.md b/support/doc/development/server.md
index 4647f2b4f..7a9fa571f 100644
--- a/support/doc/development/server.md
+++ b/support/doc/development/server.md
@@ -1,5 +1,13 @@
1# Server code 1# Server code
2 2
3## Database model typing
4
5Sequelize models contain optional fields corresponding to table joins.
6For example, `VideoModel` has a `VideoChannel?: VideoChannelModel` field. It can be filled if the SQL query joined with the `videoChannel` table or empty if not.
7It can be difficult in TypeScript to understand if a function argument expects associations to be filled or not.
8To improve clarity and reduce bugs, PeerTube defines multiple versions of a database model depending on its associations in `server/types/models/`.
9These models start with `M` and by default do not include any association. `MVideo` for example corresponds to `VideoModel` without any association, where `VideoChannel` attribute doesn't exist. On the other hand, `MVideoWithChannel` is a `MVideo` that has a `VideoChannel` field. This way, a function that accepts `video: MVideoWithChannel` argument expects a video with channel populated. Main PeerTube code should never use `...Model` (`VideoModel`) database type, but always `M...` instead (`MVideo`, `MVideoChannel` etc).
10
3## Add a new feature walkthrough 11## Add a new feature walkthrough
4 12
5Here's a list of all the parts of the server to update if you want to add a new feature (new API REST endpoints for example) to the PeerTube server. 13Here's a list of all the parts of the server to update if you want to add a new feature (new API REST endpoints for example) to the PeerTube server.