Skip to content

Commit

Permalink
add numAffectedRows @ D1Connection.executeQuery. (#14)
Browse files Browse the repository at this point in the history
* add `numAffectedRows` @ `D1Connection.executeQuery`.

* bump kysely to 0.23.x.
  • Loading branch information
igalklebanov authored Jan 13, 2023
1 parent fc360d5 commit dce5e8f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 28 deletions.
28 changes: 14 additions & 14 deletions example/package-lock.json

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

4 changes: 2 additions & 2 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"deploy": "wrangler publish"
},
"dependencies": {
"kysely": "^0.22.0",
"kysely-d1": "^0.0.5"
"kysely": "^0.23.3",
"kysely-d1": "^0.0.6"
}
}
19 changes: 9 additions & 10 deletions 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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"devDependencies": {
"@cloudflare/workers-types": "^3.17.0",
"@tsconfig/node14": "^1.0.3",
"kysely": "^0.22.0",
"kysely": "^0.23.3",
"prettier": "^2.7.1",
"typescript": "^4.8.4"
}
Expand Down
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,14 @@ class D1Connection implements DatabaseConnection {
throw new Error(results.error);
}

const numAffectedRows = results.changes > 0 ? BigInt(results.changes) : undefined;

return {
insertId: results.lastRowId === undefined || results.lastRowId === null ? undefined : BigInt(results.lastRowId),
rows: (results?.results as O[]) || [],
numUpdatedOrDeletedRows: results.changes > 0 ? BigInt(results.changes) : undefined,
numAffectedRows,
// @ts-ignore deprecated in kysely >= 0.23, keep for backward compatibility.
numUpdatedOrDeletedRows: numAffectedRows,
};
}

Expand Down

0 comments on commit dce5e8f

Please sign in to comment.