Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Skye-31 committed Sep 30, 2022
1 parent 28356d0 commit 9b4c0c1
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,17 @@ This package is recommended to be used with [@cloudflare/workers-types](https://

```ts
import { D1Orm, DataTypes, Model } from "d1-orm";
import type { Infer } from "d1-orm";

export interface Env {
// from @cloudflare/workers-types
DB: D1Database;
}

type User = {
id: number;
name: string;
email: string | undefined;
};

export default {
async fetch(request: Request, env: Env) {
const orm = new D1Orm(env.DB);
const users = new Model<User>(
const users = new Model(
{
D1Orm: orm,
tableName: "users",
Expand All @@ -58,6 +53,14 @@ export default {
},
}
);
type User = Infer<typeof users>;

await users.First({
where: {
id: 1,
},
});
// Promise<User | null>
},
};
```
Expand Down

0 comments on commit 9b4c0c1

Please sign in to comment.