Hello guys, I have created a worker which helps me to execute a cron which read data from a specific

Hello guys,
I have created a worker which helps me to execute a cron which read data from a specific KV, and for each of those data make an API call and save the result into a database.

The response saved match the following interface:
export interface IWebsiteVerificationReport {
    domain: string,
    slug: string,
    verification: string,
    status: boolean,
    message: string,
    sanityDocId: string,
    audience: string,
    location?: string,
    runAt?: Date
}


I have created a class to handle the database related operations and it was working very well. see database file.

So as I said it was working very well, but as API call was too much I decided to include a Durable object to execute my API calls in queue. I added then the following line to the entry point file:
export { RequestQueue } from "./storage/requestQueue";


And for my d1 and durable object configuration in my wrangler toml I added those lines:
durable_objects.bindings = [{ name = "REQUEST_QUEUE", class_name = "RequestQueue" }]

d1_databases = [
  { binding = "DB", database_name = "lightmode-store", database_id = "c1766ce5-234c-401b-a854-d614c5c1d300" },
]

[[migrations]]
tag = "v1"
new_classes = ["RequestQueue"]
new_databases = ["lightmode-store"]


However, after having added the durable object to it, at the step of the database insertion data I get the error "Error: TypeError: dba.prepare is not a function".
When I stringify the D1 database to inspect it I get the following object:
{
  "alwaysPrimarySession": {
    "fetcher": {},
    "bookmarkOrConstraint": "first-primary"
  },
  "fetcher": {}
}


Can someone help me resolve the issue please ?
Thanks,
Was this page helpful?