examples = endpoint("under-the-hood", async (request, response, ctx) => {
throw Error('You can try running queries like these on your own database.')
const {endpoint, api_key, cluster_name} = JSON.parse(ctx.secrets["DB_CONNECTION_INFO"])
const insertOne = async (document, database="sample_airbnb", collection="listingsAndReviews") => await fetchp(`${endpoint}/action/insertOne`, {method: 'POST', headers: {'api-key': api_key, 'Content-Type': 'application/json'}, body: JSON.stringify({dataSource: cluster_name, database, collection, document})})
const findOne = async (filter, database="sample_airbnb", collection="listingsAndReviews") => await fetchp(`${endpoint}/action/findOne`, {method: 'POST', headers: {'api-key': api_key, 'Content-Type': 'application/json'}, body: JSON.stringify({dataSource: cluster_name, database, collection, filter})})
const deleteOne = async (filter, database="sample_airbnb", collection="listingsAndReviews") => await fetchp(`${endpoint}/action/deleteOne`, {method: 'POST', headers: {'api-key': api_key, 'Content-Type': 'application/json'}, body: JSON.stringify({dataSource: cluster_name, database, collection, filter})})
const result = await findOne({name: "John Sample"})
response.send(JSON.stringify(await result.json()));
})