Cannot make D1 requests twice?
I am facing a strange issue where I am unable to make D1 queries multiple times. Here is the code I am using
If I run this code the console shows the first log is normal, but the second console.log returns undefined. What is going on here and how do I fix it?
let sqlQuery = `SELECT sura, aya, text FROM en_pickthall WHERE 1=1 `;
keywords.forEach((keyword, index) => {
sqlQuery += `AND (`;
sqlQuery += `text LIKE '% ${keyword} %' `;
sqlQuery += `OR text LIKE '% ${keyword}.' `;
sqlQuery += `OR text LIKE '% ${keyword},' `;
sqlQuery += `OR text LIKE '% ${keyword}?' `;
sqlQuery += `OR text LIKE '% ${keyword}!' `;
sqlQuery += `OR text LIKE '% ${keyword}%' `;
sqlQuery += `) `;
});
sqlQuery += `LIMIT ${limit};`;
// Execute the query
let { results } = await env.DB.prepare(sqlQuery).all();
console.log(results)
let { contextVerses } = await env.DB.prepare(sqlQuery).all();
console.log(contextVerses);let sqlQuery = `SELECT sura, aya, text FROM en_pickthall WHERE 1=1 `;
keywords.forEach((keyword, index) => {
sqlQuery += `AND (`;
sqlQuery += `text LIKE '% ${keyword} %' `;
sqlQuery += `OR text LIKE '% ${keyword}.' `;
sqlQuery += `OR text LIKE '% ${keyword},' `;
sqlQuery += `OR text LIKE '% ${keyword}?' `;
sqlQuery += `OR text LIKE '% ${keyword}!' `;
sqlQuery += `OR text LIKE '% ${keyword}%' `;
sqlQuery += `) `;
});
sqlQuery += `LIMIT ${limit};`;
// Execute the query
let { results } = await env.DB.prepare(sqlQuery).all();
console.log(results)
let { contextVerses } = await env.DB.prepare(sqlQuery).all();
console.log(contextVerses);If I run this code the console shows the first log is normal, but the second console.log returns undefined. What is going on here and how do I fix it?