Last active
January 11, 2020 02:37
-
-
Save jimthedev/7c44d77645dd4f9e62e0a786c8fd4739 to your computer and use it in GitHub Desktop.
faunadb incrementbyid function
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
Call(Function("increment"), "topics", "254119747652682260", [ | |
"data", | |
"clickCount" | |
]); | |
/* | |
each document in the topics collection looks like this: | |
{ | |
"slug": "dev", | |
"clickCount": 14 | |
} | |
*/ |
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
Query( | |
Lambda( | |
["collection", "id", "path"], | |
Update(Ref(Collection(Var("collection")), Var("id")), { | |
data: { | |
clickCount: Add( | |
Select( | |
Var("path"), | |
Get(Ref(Collection(Var("collection")), Var("id"))) | |
), | |
1 | |
) | |
} | |
}) | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment