Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hukusuke1007/firestore_data_modeling_design
firestore data modeling design
https://github.com/hukusuke1007/firestore_data_modeling_design
ballcap dart firebase firestore freezed typescript yaml
Last synced: about 5 hours ago
JSON representation
firestore data modeling design
- Host: GitHub
- URL: https://github.com/hukusuke1007/firestore_data_modeling_design
- Owner: hukusuke1007
- Created: 2021-10-11T15:19:40.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-09T17:02:07.000Z (almost 3 years ago)
- Last Synced: 2024-11-13T23:12:33.692Z (5 days ago)
- Topics: ballcap, dart, firebase, firestore, freezed, typescript, yaml
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/fdmd
- Size: 102 KB
- Stars: 9
- Watchers: 2
- Forks: 2
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# fdmd
Firebase Data Modeling Desing Tool. yaml => firestore modeling code.
https://www.npmjs.com/package/fdmd
## Install
Install to your project (recommand).
```sh
npm install --save-dev fdmd
```## Run
Copy from yaml dir and template dir to your current directory.
[yaml](./yaml/)
[template](./template/)```sh
# generate code
node_modules/.bin/fdmd# generate code with options
node_modules/.bin/fdmd --generate all --inputFile yaml/db.yaml --tempDir template
```| command options | details | remarks |
| --------------- | --------------------------------------- | -------------------------------- |
| --generate | all (default `all`) | auto generate code type |
| --inputFile | modeling yaml (default `yaml/db.yaml` ) | input data to auto generate code |
| --tempDir | template code (default `template`) | input data to auto generate code |### Support language
| generate code | support | command | generate code example |
| -------------------------- | ------- | ---------------- | ----------------------------------------------- |
| All | ◯ | all | [code](./example/fdmd_output/) |
| Dart | - | - | - |
| Dart - Freezed | ◯ | dart_freezed | [code](./example/fdmd_output/dart_freezed/) |
| TypeScript | - | - | - |
| TypeScript - Ballcap-Admin | ◯ | ts_ballcap_admin | [code](./example/fdmd_output/ts_ballcap_admin/) |
| Swift | - | - | - |
| Swift - Ballcap | - | - | - |
| Kotlin | - | - | - |## Data Modeling
Can be design data modeling with yaml file.
| type | support |
| --------- | ------- |
| string | ◯ |
| int | ◯ |
| double | ◯ |
| timestamp | ◯ |
| map | ◯ |
| array | ◯ |
| any | ◯ |
| bool | ◯ |
| nullable | ◯ |### How to design yaml
[yaml sample](./yaml/db.yaml)
#### Document
```yaml
docs: # add
- name: Poster
path: /social/${socialId}/posters/${posterId}
description: 投稿者の情報
codeGenerate: true # code generate
data:
- field: id
type: string # non nullable
example: DocumentId
- field: name
type: string,nullable # nullable
example: ケン
- field: age
type: int,nullable
example: 10
- field: createdAt
type: timestamp,nullable
example: '2021-09-16T13:10:52+09:00'
- field: updatedAt
type: timestamp,nullable
example: '2021-09-16T13:10:52+09:00'
```Map model
```yaml
maps: # add
- name: ThumbnailImage
description: 画像情報
codeGenerate: true
data:
- field: url
type: string
example: https://sample/image.jpg
- field: path
type: string
example: /social/${socialId}/users/${userId}/images/${imageId}
```Reference map model
```yaml
docs:
- name: Poster
path: /social/${socialId}/posters/${posterId}
description: 投稿者の情報
codeGenerate: true
data:
- field: image
type: map,nullable
map:
reference: ThumbnailImage # add. same maps name
maps:
- name: ThumbnailImage # add. same docs name
description: 画像情報
codeGenerate: true
data:
- field: url
type: string
example: https://sample/image.jpg
- field: path
type: string
example: /social/${socialId}/users/${userId}/images/${imageId}
```#### Collection
```yaml
docs:
- name: Poster
path: /social/${socialId}/posters/${posterId}
description: 投稿者の情報
codeGenerate: true
data:
- field: name
type: string,nullable
example: ケン
collections: # add
- field: posts
type: Post
- name: Post
path: /social/${socialId}/posters/${posterId}/posts/${postId}
description: 投稿情報
codeGenerate: true
data:
- field: title
type: string,nullable
example: タイトル
- field: text
type: string,nullable
example: テキスト内容
```