import client from "../../utils/fauna.js";
import { fql } from "fauna";
export default defineEventHandler(async (event) => {
const collectionName = "customers";
const collectionExists = (name) => fql`Collection.byName(${name}) != null`;
// define a new query that uses the prior sub-query
const upsertCollectionQuery = fql`
if (${collectionExists(collectionName)}) {
"Collection exists!"
} else {
Collection.create({ name: ${collectionName} })
"Collection exists now!"
}
`;
// execute the query
const customers = await client.customers.all();
client.close();
return customers;
});
This just tells me the collection exists
Trying to get my doccuments from 'customers collection but I cannot figure it out.
Docs are all over the place