Interactions-as-a-Service / d1-orm

A simple, strictly typed ORM, to assist you in using Cloudflare's D1 product
https://docs.interactions.rest/d1-orm/
Apache License 2.0
161 stars 10 forks source link

feat: update to latest D1 Database interface #71

Closed dtbuchholz closed 1 year ago

dtbuchholz commented 1 year ago

Summary

The D1 Database exec method has changed an now expects a ExecResult instead of a Result<T>. If you're using the latest @cloudflare/workers-types, the ORM response will be incorrect for methods like CreateTable or DropTable, which use exec under the hood. This PR bumps to the latest version and makes slight changes to fix this return type.

Details

The latest D1 APIs can be found here. The is what exec looks like:

exec(query: string): Promise<D1ExecResult>;

And D1ExecResult:

interface D1ExecResult {
  count: number;
  duration: number;
}

The proposed changes simply swap out the outdated return type of D1Result<T> for D1ExecResult where needed. Also, chai was updated in order to fix an import issue in the tests.

How it was tested

After updating these deps and making slight changes to database.ts and model.ts, the tests pass without needing any changes.

changeset-bot[bot] commented 1 year ago

🦋 Changeset detected

Latest commit: f96d35e552d4bed8eff2a204330a5cc85803acbd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ------ | ----- | | d1-orm | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR