Closed probablykasper closed 1 year ago
Hi,
The D1 Client API document states the following
The methods stmt.run(), stmt.all() and db.batch() return an object that contains the results (if applicable), the success status, and a meta object with the internal duration of the operation in milliseconds.
The D1Result type provided by the workers-types library in version 3.18.0 does not seem to have "success" and "meta" properties.
declare type D1Result<T = unknown> = {
results?: T[];
lastRowId: number | null;
changes: number;
duration: number;
error?: string;
};
It seems that the D1Result types defined in the "override" directory in the workers-types repository have not been merged.
Also, when I actually run the query, the return value of the query has the "success" property but not the "meta" property, and instead has the "duration" property.
I am contacting you just in case.
Hey! This has been fixed in @cloudflare/workers-types@4
. 👍
There seems to be a lot of incorrect types for D1
Two examples (I'm sure there are others):
error
property. The docs say that errors are thrown and never mention theerror
property, so I'm not sure if that one really exists.D1PreparedStatement.run()
has aresults?
property, even though the docs say that.run()
returns no results (same goes forexec
I think)