What I did so far is I created a query to get all Authors, and I created a query for getting all published book by authors, my problem is that I cant filter what author published book on transaction. What i want is to count all author published book on transaction
This is my code
const getAuthors = async ()=>{
return new Promise((resolve, reject)=>{
var author = (`SELECT id, name FROM Author`, 1000, data=>{
let obj = { authorsId: [] }
for(let x = 0; x < data.length; x++){
obj.authorsId.push(data[x][0]);
}
console.log(obj)
return resolve(obj);
})
})
}
result of console.log(obj)
{
"authorsId": [
1,
2,
3,
4
]
}
/
const getAuthorPublished = async ()=>{
const authorsId = await getAuthors()
return new Promise((resolve, reject)=>{
var bookpublished = (`SELECT exp_fAuthor, rAuthors, exp_fAuthor_Published_Book FROM KTMS_Transaction`, 1000, data=>{
let arrAuthorPublished = { authors: [], authorIds: [], counts: [] }
for(let x = 0; x < data.length; x++){
arrAuthorPublished.authors.push(data[x][0]);
arrAuthorPublished.authorIds.push(data[x][1]);
arrAuthorPublished.counts.push(data[x][2]);
}
console.log("arrAuthorPublished: ", arrAuthorPublished)
return resolve(arrAuthorPublished);
})
})
}
//result of console.log(arrAuthorPublished)
{
"authors": [
"Claire",
"Claire",
"Yuno",
"Claire"
],
"authorIds": [
440944522,
440944522,
440930072,
440944522
],
"counts": [
1,
1,
1,
1
]
}