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 from the driver:
var faunadb = require('./index')
var q = faunadb.query
function account (res) {
if (!res || !res.responseHeaders) return
h = res.responseHeaders
console.log(h)
}
var client = new faunadb.Client({
secret: 'secret',
domain: 'localhost',
port: 8443,
scheme: 'http',
observer: account
})
The FaunaDB dashboard does it by hooking it
into API.selectDatabase
:
type ApiConfig = {
urlString: string
secret: string
opts?: ClientConfig
}
export const selectDatabase = (path: string | null | undefined, opts: ClientConfig): void => {
const secret = path ? createDatabaseSecret(path) : rootSecret()
connect({
...apiConfig,
secret,
opts
})
}