I have a Fauna database with a collection "rooms" and an index "all_rooms_by_name"
I can run the query
Map(
Paginate(Match(Index("all_rooms_by_name"), "57|65")),
Lambda("roomRef", Get(Var("roomRef")))
)
in the Fauna shell and I get the expected response
[
{
data: [Collection("rooms")]
},
{
data: [
Index("all_rooms_by_name")
]
},
{
data: [
{
ref: Ref(Collection("rooms"), "336166823854604873"),
ts: 1656852515940000,
data: {
name: "57|65",
users: {}
}
}
]
}
]
I am trying to emulate this in javascript using the Fauna docs
const faunadb = require("faunadb");
const query = faunadb.query;
const client = new faunadb.Client({
secret: process.env.FAUNA_SECRET
});
var query_function = client.paginate(
query.Match(
query.Index('all_rooms_by_name'),
'57|65'
)
)
var response = await client.query(query_function)
But it returns an error and response contains {}. What am I doing wrong?