This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { client, q } from '../config/db' | |
const deleteNote = noteRef => client.query( | |
q.Delete(q.Ref(q.Collection('notes'), noteRef)) | |
) | |
.then(res => res) | |
.catch(err => console.warn(err.message)) | |
export default deleteNote |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { client, q } from '../config/db' | |
const editNote = (noteId, newText) => client.query( | |
q.Update( | |
q.Ref(q.Collection('notes'), noteId), | |
{ data: { text: newText } }, | |
) | |
) | |
.then((ret) => console.log(ret)) | |
.catch(err => console.warn(err)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { client, q } from '../config/db' | |
const getAllNotes = client.query( | |
q.Paginate( | |
q.Match( | |
q.Ref('indexes/all_notes'))) | |
) | |
.then(response => { | |
const notesRefs = response.data | |
// create new query out of notes refs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import faunadb from 'faunadb' | |
const client = new faunadb.Client({ secret: process.env.REACT_APP_FAUNADB_KEY }) | |
const q = faunadb.query | |
export { client , q } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect, useState } from 'react'; | |
import getAllProducts from './fauna/get-all-products.js' | |
function App() { | |
const [data, setData] = useState('') | |
useEffect(() => { | |
getAllProducts.then(data => setData(data)) | |
}, []) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect, useState } from 'react'; | |
function App() { | |
const [data, setData] = useState('') | |
useEffect(() => { | |
fetch('/.netlify/functions/hello-world') | |
.then((response) => response.json()) | |
.then(data => setData(data)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect, useState } from 'react'; | |
function App() { | |
const [data, setData] = useState('') | |
useEffect(() => { | |
fetch('/.netlify/functions/hello-world') | |
.then((response) => response.json()) | |
.then(data => setData(data)) |