Skip to content

Commit

Permalink
0.0.5 (#6)
Browse files Browse the repository at this point in the history
* Update README

* Update package.json

* @WalshyDev made me fix my readme

* Update README.md

Co-authored-by: Daniel Walsh <[email protected]>

* Update README.md

Co-authored-by: Daniel Walsh <[email protected]>

* bump example to 0.0.5

Co-authored-by: Daniel Walsh <[email protected]>
  • Loading branch information
aidenwallis and WalshyDev authored Oct 22, 2022
1 parent 765e841 commit ad1088d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,23 @@ interface Database {
export default {
async fetch(request: Request, env: Env): Promise<Response> {
const { searchParams } = new URL(request.url);
const action = searchParams.get('action');
const key = searchParams.get('key');
const value = searchParams.get('value');
if (!key) {
return new Response('No key defined.', { status: 400 });
}

// Create Kysely instance with kysely-d1
const db = new Kysely<Database>({ dialect: new D1Dialect({ database: env.DB }) });

// Read row from D1 table
const result = await db.selectFrom('kv').selectAll().where('key', '=', key).executeTakeFirst();
if (!result) {
return new Response('No value found', { status: 404 });
}

return new Response(result.value);
},
};
```

There is a working [example](example) also included, that implements a K/V style store using D1.
There is a working [example](example) also included, which implements a K/V style store using D1.
14 changes: 7 additions & 7 deletions example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
},
"dependencies": {
"kysely": "^0.22.0",
"kysely-d1": "^0.0.4"
"kysely-d1": "^0.0.5"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "kysely-d1",
"description": "Kysely dialect for Cloudflare D1",
"main": "./dist/index.js",
"version": "0.0.4",
"version": "0.0.5",
"types": "./dist/index.d.ts",
"repository": "[email protected]:aidenwallis/kysely-d1.git",
"author": "Aiden <[email protected]>",
Expand Down

0 comments on commit ad1088d

Please sign in to comment.