Skip to content

Instantly share code, notes, and snippets.

@jimthedev
Last active January 11, 2020 02:37
Show Gist options
  • Save jimthedev/7c44d77645dd4f9e62e0a786c8fd4739 to your computer and use it in GitHub Desktop.
Save jimthedev/7c44d77645dd4f9e62e0a786c8fd4739 to your computer and use it in GitHub Desktop.
faunadb incrementbyid function
Call(Function("increment"), "topics", "254119747652682260", [
"data",
"clickCount"
]);
/*
each document in the topics collection looks like this:
{
"slug": "dev",
"clickCount": 14
}
*/
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