Codename_A
Codename_A
Explore posts from servers
CDCloudflare Developers
Created by Codename_A on 7/21/2024 in #pages-help
Sveltekit with pages giving errors
I have attached the log. This is with a sveltekit application. Please help
4 replies
CDCloudflare Developers
Created by Codename_A on 7/10/2024 in #workers-help
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
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?
7 replies
CDCloudflare Developers
Created by Codename_A on 4/30/2024 in #general-help
What is the best way to do this?
I'm unsure if using workers for this case would work: I want to make openai api requests in the back end without showing the user my api key. Something like an api proxy. Of course, then I would need to authenticate to make sure regular people couldn't just use that to make requests. Could workers be a use case for this? Or another product. How would I do this>
2 replies