Skip to content

Instantly share code, notes, and snippets.

@indreklasn
Created December 6, 2019 14:43
Show Gist options
  • Save indreklasn/5dea84effa4cf8696d73435771eccf6c to your computer and use it in GitHub Desktop.
Save indreklasn/5dea84effa4cf8696d73435771eccf6c to your computer and use it in GitHub Desktop.
import { client, q } from './db'
const getAllProducts = client.query(
q.Paginate(
q.Match(
q.Ref('indexes/all_products')))
)
.then((response) => {
const productRefs = response.data
// create new query out of todo refs.
// https://docs.fauna.com/fauna/current/api/fql/
const getAllProductDataQuery = productRefs.map((ref) => {
return q.Get(ref)
})
// query the refs
return client.query(getAllProductDataQuery).then((data) => data)
})
.catch((error) => console.log('error', error.message))
export default getAllProducts;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment