Last active
June 15, 2022 12:05
-
-
Save glommer/335696423126c2634fa6855f1a347688 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Validating emails with email-validator. | |
// Validation happens inline, straight inside the arrow function | |
const user = await User.findOne(user => user.name == "Glauber Costa" && | |
user.age >= 40 && | |
validate(user.email)); | |
return new Response(user?.email ?? "not found"); | |
// Same code, but now splitting database and runtime code out-of-line. | |
// The results are equivalent in ChiselStrike. | |
const user = await User.findOne(user => user.name == "Glauber Costa" && user.age >= 40); | |
return new Response(validate(user?.email) ? user.email : "not found"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment