update env key to FAUNADB_SERVER_SECRET

This commit is contained in:
DavidWells 2019-04-07 15:49:58 -07:00
parent 9b089e7c04
commit 271721bbc0
11 changed files with 18396 additions and 111 deletions

View file

@ -6,28 +6,28 @@ const client = new faunadb.Client({
})
exports.handler = (event, context, callback) => {
console.log("Function `todo-read-all` invoked")
return client.query(q.Paginate(q.Match(q.Ref("indexes/all_todos"))))
.then((response) => {
const todoRefs = response.data
console.log("Todo refs", todoRefs)
console.log(`${todoRefs.length} todos found`)
// create new query out of todo refs. http://bit.ly/2LG3MLg
const getAllTodoDataQuery = todoRefs.map((ref) => {
return q.Get(ref)
})
// then query the refs
return client.query(getAllTodoDataQuery).then((ret) => {
console.log('Function `todo-read-all` invoked')
return client.query(q.Paginate(q.Match(q.Ref('indexes/all_todos'))))
.then((response) => {
const todoRefs = response.data
console.log('Todo refs', todoRefs)
console.log(`${todoRefs.length} todos found`)
// create new query out of todo refs. http://bit.ly/2LG3MLg
const getAllTodoDataQuery = todoRefs.map((ref) => {
return q.Get(ref)
})
// then query the refs
return client.query(getAllTodoDataQuery).then((ret) => {
return callback(null, {
statusCode: 200,
body: JSON.stringify(ret)
})
})
}).catch((error) => {
console.log('error', error)
return callback(null, {
statusCode: 200,
body: JSON.stringify(ret)
statusCode: 400,
body: JSON.stringify(error)
})
})
}).catch((error) => {
console.log("error", error)
return callback(null, {
statusCode: 400,
body: JSON.stringify(error)
})
})
}