update env key to FAUNADB_SERVER_SECRET
This commit is contained in:
parent
9b089e7c04
commit
271721bbc0
11 changed files with 18396 additions and 111 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import faunadb from 'faunadb'
|
||||
import getId from './utils/getId'
|
||||
|
||||
const q = faunadb.query
|
||||
const client = new faunadb.Client({
|
||||
|
|
@ -9,24 +8,24 @@ const client = new faunadb.Client({
|
|||
exports.handler = (event, context, callback) => {
|
||||
const data = JSON.parse(event.body)
|
||||
console.log('data', data)
|
||||
console.log("Function `todo-delete-batch` invoked", data.ids)
|
||||
console.log('Function `todo-delete-batch` invoked', data.ids)
|
||||
// construct batch query from IDs
|
||||
const deleteAllCompletedTodoQuery = data.ids.map((id) => {
|
||||
return q.Delete(q.Ref(`classes/todos/${id}`))
|
||||
})
|
||||
// Hit fauna with the query to delete the completed items
|
||||
return client.query(deleteAllCompletedTodoQuery)
|
||||
.then((response) => {
|
||||
console.log("success", response)
|
||||
return callback(null, {
|
||||
statusCode: 200,
|
||||
body: JSON.stringify(response)
|
||||
.then((response) => {
|
||||
console.log('success', response)
|
||||
return callback(null, {
|
||||
statusCode: 200,
|
||||
body: JSON.stringify(response)
|
||||
})
|
||||
}).catch((error) => {
|
||||
console.log('error', error)
|
||||
return callback(null, {
|
||||
statusCode: 400,
|
||||
body: JSON.stringify(error)
|
||||
})
|
||||
})
|
||||
}).catch((error) => {
|
||||
console.log("error", error)
|
||||
return callback(null, {
|
||||
statusCode: 400,
|
||||
body: JSON.stringify(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue