Firebase Data Modeling Desing Tool. yaml => firestore modeling code.
https://www.npmjs.com/package/fdmd
Install to your project (recommand).
npm install --save-dev fdmd
Copy from yaml dir and template dir to your current directory.
# 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 |
generate code | support | command | generate code example |
---|---|---|---|
All | ◯ | all | code |
Dart | - | - | - |
Dart - Freezed | ◯ | dart_freezed | code |
TypeScript | - | - | - |
TypeScript - Ballcap-Admin | ◯ | ts_ballcap_admin | code |
Swift | - | - | - |
Swift - Ballcap | - | - | - |
Kotlin | - | - | - |
Can be design data modeling with yaml file.
type | support |
---|---|
string | ◯ |
int | ◯ |
double | ◯ |
timestamp | ◯ |
map | ◯ |
array | ◯ |
any | ◯ |
bool | ◯ |
nullable | ◯ |
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
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
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}
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: テキスト内容