A boolean is true or false. As a schema field it is written active: boolean,
and the literals are true and false. Comparisons and the boolean operators
(and, or, not) also produce booleans.
active = true
adult = age >= 18
route GET "/account/:id"
account = db.accounts.find(params.id)
require account.active else fail 403, "account is disabled"
reply 200, accountBooleans are the clearest values to use in require and allow. Guards also use
truthiness, so null and false stop the flow.
Notes
- A
booleanhas no methods. You combine booleans withand,or, andnot(see Keywords). cache.get,db.<table>.find, and similar returnnullwhen absent, which is falsy, so you can guard them withrequire value else ...directly.