Querying actual collection

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

Hi @R0N1n-dev It looks like you are using a custom client object here. Can you share what FQL you are running?

Hi @R0N1n-dev we haven’t heard back yet. Do you still need assistance with your query?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.