add path id util
This commit is contained in:
parent
4c794b23f3
commit
5a0a7e495c
5 changed files with 16 additions and 7 deletions
|
|
@ -9,13 +9,15 @@ 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) => {
|
||||
console.log("success", response)
|
||||
const newQuery = response.data.map((ref) => {
|
||||
console.log('ref', ref)
|
||||
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(newQuery).then((ret) => {
|
||||
return client.query(getAllTodoDataQuery).then((ret) => {
|
||||
return callback(null, {
|
||||
statusCode: 200,
|
||||
body: JSON.stringify(ret)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue