Site : https://bbochat.netlify.app
My app accesses a fauna database and the function (db-access.js) that I use relates to Fauna V4
const faunadb = require("faunadb");
const query = faunadb.query;
const client = new faunadb.Client({
secret: process.env.FAUNADB_SECRET_BBO_CHAT,
domain: process.env.FAUNADB_DOMAIN,
port: process.env.FAUNADB_PORT,
scheme: process.env.FAUNADB_SCHEME,
})
exports.handler = async (key, index) => {
query_function = query.Map(
query.Paginate(query.Match(query.Index(index), key)),
(recordRef) => query.Get(recordRef)
);
var response = await client.query(query_function);
return {
statusCode: 200,
body: JSON.stringify(response.data),
};
}
When I try using the V10 recommendations I get an error
Function db-access has returned an error: faunadb.fql is not a function
But I cannot locate the docs that cover the faunadb object
The V10 code I use is
exports.handler = async (collection, key, index) => {
query_function = client.query(faunadb.fql`${collection}.${index}(${key}).first()`)
var response = await client.query(query_function);
return {
statusCode: 200,
body: JSON.stringify(response.data),
};
}