Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to get data from FaunaDB by Index. Usually gets singular data.
import os
from faunadb import query as q
from faunadb.objects import Ref
from faunadb.client import FaunaClient
def get(index, data):
try:
serverClient = FaunaClient(secret=os.environ.get("FAUNA_SERVER_SECRET"))
res = serverClient.query(q.get(q.match(q.index(index), data)))
res["data"]["ref_id"] = res["ref"].id()
return res["data"]
except Exception as ex:
raise ex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment