Skip to content

Instantly share code, notes, and snippets.

View n400's full-sized avatar

Summer Schrader n400

View GitHub Profile
@n400
n400 / expose-response-headers.md
Created May 8, 2020 14:24
Example observers to expose response headers from FaunaDB JS driver

When the FaunaDB JavaScript driver returns query results, it's exposing the the response payload, but not the response headers. However, the response headers contain query metrics you might want (e.g., read ops, write ops, transaction retires, query time, bytes in/out, storage bytes read/written, read ops).

The web shell/REPL at dashboard.fauna.com also presents this information to you through the GUI (click the "i" on left).

Here are some examples to help you get the repsonse headers

@n400
n400 / tokens.md
Last active May 26, 2020 10:54
Unofficial documentation on FaunaDB's Tokens() function

Tokens

Tokens( )

Description

The Tokens function provides access to the system collection that stores access tokens, created with the Login function. This is useful for:

  • Listing currently existing tokens
# Recursion UDF from FaunaDB Community user
---
Q: Is there an approved way to loop/repeat FQL an arbitrary number of times? Or generate a set/array of arbitrary size to Foreach on?
A: You can play with UDF to achieve it. Here is a quick idea (using recursion, careful it's max 200 iterations).
Calling it would be something like this Call("Repeat", ["3", "AnotherFunctionName", 0]) .
It's really just an example, you can mess around it to add input values if needs be, etc.
const Repeat = Query(
{ "name": "Hybrid Cluster 1",
"children": [
{
"name": "Replica 1",
"children": [
{"name": "Node 1", "size": 25},
{"name": "Node 2", "size": 25},
{"name": "Node 3", "size": 25},
{"name": "Node 4", "size": 25},
{"name": "Node 5", "size": 25},