Skip to content

Commit

Permalink
Merge branch '0b5vr-docs-database'
Browse files Browse the repository at this point in the history
  • Loading branch information
doxas committed Dec 23, 2022
2 parents e76eb2d + 432b60c commit efaf481
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 1 deletion.
143 changes: 143 additions & 0 deletions database-structure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# Database Structure

twigl uses [Firebase Realtime Database](https://firebase.google.com/products/realtime-database?hl=ja) to manage data of the broadcast mode.

## `director`

`director` is an object from director ID to `Director`.

`Director` is like a user per session.
`Director` has information about the director.

```ts
interface Director {
/**
* The screen name of the director.
*/
name: string;
};
```

## `channel`

`channel` is an object from channel ID to `Channel`.

`Channel` has code, cursor position, and stuff for the channel.

It also has three director IDs:

- director ID for the screen name and the session URL
- director ID represents the graphics coder (VJ)
- director ID represents the sound coder (DJ)

```ts
/**
* Mode of the regulation in the graphics code.
*/
enum GraphicsMode {
Classic = 0,
Geek = 1,
Geeker = 2,
Geekest = 3,
Classic300 = 4,
Geek300 = 5,
Geeker300 = 6,
Geekest300 = 7,
ClassicMRT = 8,
GeekMRT = 9,
GeekerMRT = 10,
GeekestMRT = 11,
}

interface Channel {
/**
* The director ID for the Channel.
*/
directorId: string;

/**
* The director ID of the graphics coder (VJ).
* It can be `'unknown'` if the coder is not there.
*/
visual: string;

/**
* The director ID of the sound coder (DJ).
* It can be `'unknown'` if the coder is not there.
*/
disc: string;

/**
* Always `true`?
*/
initialized: boolean;

graphics: {
/**
* Represents the current cursor position.
* row, column, and scrollTop.
* They are represented in the format like `'10|22|2'`.
*/
cursor: string;

/**
* The current graphics mode (regulation)
*/
mode: GraphicsMode;

/**
* The GLSL code of the graphics.
*/
source: string;
};

sound: {
/**
* Represents the current cursor position.
* row, column, and scrollTop.
* They are represented in the format like `'10|22|2'`.
*/
cursor: string;

/**
* The counter increments when the coder hits the play button.
*/
play: number;

/**
* The GLSL code of the sound.
*/
source: string;
}
}
```

## `viewer`

`viewer` is an object from channel ID to `Viewer`.

`Viewer` has information about viewers of the channel.

```ts
interface Viewer {
/**
* The counter represents the current viewer.
*/
count: number;
}
```

## `star`

`star` is an object from channel ID to `Star`.

`Star` has information about reactions (♥) to the channel.

```ts
interface Star {
/**
* The counter represents the current reaction count (♥).
*/
count: number;
}
```
2 changes: 1 addition & 1 deletion src/firedb.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class FireDB {
constructor(firebase){
/**
* Firebase の Database インスタンス
* @type {Database}
* @type {import('firebase/app').database.Database}
*/
this.db = firebase.database();
}
Expand Down

0 comments on commit efaf481

Please sign in to comment.