query for all data
This commit is contained in:
parent
fd5b183d00
commit
4c794b23f3
2 changed files with 11 additions and 4 deletions
|
|
@ -7,7 +7,7 @@ const client = new faunadb.Client({
|
|||
|
||||
exports.handler = (event, context, callback) => {
|
||||
const data = JSON.parse(event.body)
|
||||
console.log("Function `todo-create` invoked")
|
||||
console.log("Function `todo-create` invoked", data)
|
||||
return client.query(q.Create(q.Ref("classes/todos"), {data}))
|
||||
.then((response) => {
|
||||
console.log("success", response)
|
||||
|
|
|
|||
|
|
@ -10,9 +10,16 @@ exports.handler = (event, context, callback) => {
|
|||
return client.query(q.Paginate(q.Match(q.Ref("indexes/all_todos"))))
|
||||
.then((response) => {
|
||||
console.log("success", response)
|
||||
return callback(null, {
|
||||
statusCode: 200,
|
||||
body: JSON.stringify(response)
|
||||
const newQuery = response.data.map((ref) => {
|
||||
console.log('ref', ref)
|
||||
return q.Get(ref)
|
||||
})
|
||||
// then query the refs
|
||||
return client.query(newQuery).then((ret) => {
|
||||
return callback(null, {
|
||||
statusCode: 200,
|
||||
body: JSON.stringify(ret)
|
||||
})
|
||||
})
|
||||
}).catch((error) => {
|
||||
console.log("error", error)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue