Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
342
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
25
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TransFem.org
Sharkey
Commits
daf9a449
Unverified
Commit
daf9a449
authored
5 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
Update CONTRIBUTING.md
parent
960268fd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CONTRIBUTING.md
+19
-0
19 additions, 0 deletions
CONTRIBUTING.md
with
19 additions
and
0 deletions
CONTRIBUTING.md
+
19
−
0
View file @
daf9a449
...
...
@@ -137,3 +137,22 @@ SQLでは配列のインデックスは**1始まり**。
### `undefined`にご用心
MongoDBの時とは違い、findOneでレコードを取得する時に対象レコードが存在しない場合
**`undefined`**
が返ってくるので注意。
MongoDBは
`null`
で返してきてたので、その感覚で
`if (x === null)`
とか書くとバグる。代わりに
`if (x == null)`
と書いてください
### 簡素な`undefined`チェック
データベースからレコードを取得するときに、プログラムの流れ的に(ほぼ)絶対
`undefined`
にはならない場合でも、
`undefined`
チェックしないとTypeScriptに怒られます。
でもいちいち複数行を費やして、発生するはずのない
`undefined`
をチェックするのも面倒なので、
`ensure`
というユーティリティ関数を用意しています。
例えば、
```
ts
const
user
=
Users
.
findOne
(
userId
);
// この時点で user の型は User | undefined
if
(
user
==
null
)
{
throw
'
missing user
'
;
}
// この時点で user の型は User
```
という処理を
`ensure`
を使うと
```
ts
const
user
=
Users
.
findOne
(
userId
).
then
(
esure
);
// この時点で user の型は User
```
という風に書けます。
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment