@sportsbroker/firebase-structure 3.45.0 → 3.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -5
- package/firestore/common.d.ts +7 -0
- package/firestore/index.d.ts +2 -0
- package/firestore/user-status.d.ts +17 -0
- package/index.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,6 +35,7 @@ Id's of objects are always held as it's keys in order to let build better querie
|
|
|
35
35
|
### Queries
|
|
36
36
|
|
|
37
37
|
#### Path
|
|
38
|
+
|
|
38
39
|
In order to build Firebase query it's necessary to know full path to retrieved object. There are no path queries which allow to find some node without knowing names of it's ancestor. So for such structure:
|
|
39
40
|
|
|
40
41
|
```javascript
|
|
@@ -70,13 +71,13 @@ In order to build Firebase query it's necessary to know full path to retrieved o
|
|
|
70
71
|
}
|
|
71
72
|
```
|
|
72
73
|
|
|
73
|
-
If there is necessity to retrieve object
|
|
74
|
+
If there is necessity to retrieve object _matches_ it's necessary to know id of its' parent node (_sportId_) and use it with full path `sportId/matches`. There is no sensible possibility though to retrieve matches from both _sportId_ and _sport2Id_ (the only way to do it is to retrieve full object with _teams_, _players_ and all other siblings there could be)
|
|
74
75
|
|
|
75
76
|
##### Finding path nodes
|
|
76
77
|
|
|
77
|
-
Having just such structure as above it's impossible to get
|
|
78
|
+
Having just such structure as above it's impossible to get _sportId_ and _sport2Id_ without loading whole objects and getting their keys.
|
|
78
79
|
|
|
79
|
-
It's why to retrieve such key there is necessity to build additional object where,
|
|
80
|
+
It's why to retrieve such key there is necessity to build additional object where, _sportId_ will contain only lightweight sorting and querying data, such as:
|
|
80
81
|
|
|
81
82
|
```javascript
|
|
82
83
|
{
|
|
@@ -153,7 +154,7 @@ Structure is divided into sections: **details**, **queries**, **snapshots**, and
|
|
|
153
154
|
|
|
154
155
|
Every section have on some level descendants which are list of ids of objects. Subscription should always happen on the last id node in a path in order to retrieve singular object, or on last but one for retrieving lists of data.
|
|
155
156
|
|
|
156
|
-
Most of sections contain object **overviews**. It's goal is to gather data defining its' first ancestor (such as for example
|
|
157
|
+
Most of sections contain object **overviews**. It's goal is to gather data defining its' first ancestor (such as for example _name_).
|
|
157
158
|
|
|
158
159
|
Each of sections stores slightly different types of data:
|
|
159
160
|
|
|
@@ -169,7 +170,7 @@ If some data is duplicated between sections then it shouldn't be updated the sam
|
|
|
169
170
|
|
|
170
171
|
#### matches
|
|
171
172
|
|
|
172
|
-
Contains data necessary to display detailed data of a singular match. It assumes that once client app enters such detailed match screen it has to already have id of a match.
|
|
173
|
+
Contains data necessary to display detailed data of a singular match. It assumes that once client app enters such detailed match screen it has to already have id of a match.
|
|
173
174
|
|
|
174
175
|
Important thing to notice is that once match is over no data is going to change for such match. It's why data for teams shares, venue are duplicated here (even if venue or team name changes in the future in match screen should be displayed old one). It helps to simplify logic of finding proper names depending on dates.
|
|
175
176
|
|
|
@@ -204,3 +205,7 @@ In queries section besides logical types sections level there is introduced also
|
|
|
204
205
|
1. Run `tsc && npm pack`
|
|
205
206
|
2. Copy absolute path to `sportsbroker-firebase-structure-<version>.tgz`
|
|
206
207
|
3. Run `npm install <absolute-path>` on another project
|
|
208
|
+
|
|
209
|
+
## Firestore
|
|
210
|
+
|
|
211
|
+
In **firestore** directory, we keep types for document structures that are used in **Firestore** DB which is more efficient than RealtimeDB. Convention is one file for one Firestore collection that exports types for this collection document.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { UUID } from "global";
|
|
2
|
+
import { Doc } from "./common";
|
|
3
|
+
|
|
4
|
+
export type UserStatus =
|
|
5
|
+
| "CREATED"
|
|
6
|
+
| "ACTIVATED"
|
|
7
|
+
| "EMAIL_CONFIRMED"
|
|
8
|
+
| "VERIFICATION_FAILED"
|
|
9
|
+
| "DEACTIVATED"
|
|
10
|
+
| "SELF_EXCLUDED"
|
|
11
|
+
| "BANNED"
|
|
12
|
+
| "DUPLICATED";
|
|
13
|
+
|
|
14
|
+
export type UserStatusDoc = {
|
|
15
|
+
userId: UUID;
|
|
16
|
+
status: UserStatus;
|
|
17
|
+
} & Doc;
|
package/index.d.ts
CHANGED