Skip to content

Commit

Permalink
Fix unnecessary double partial in Model
Browse files Browse the repository at this point in the history
  • Loading branch information
Skye-31 committed Nov 29, 2022
1 parent c1c002e commit 30b38c7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-suns-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"d1-orm": patch
---

Fix: Unnecessary double partial in some Model queries
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
custom: ['https://www.buymeacoffee.com/Skye31']
custom: ["https://www.buymeacoffee.com/Skye31"]
13 changes: 5 additions & 8 deletions src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export class Model<T extends Record<string, ModelColumn>> {
* @returns Returns the first row that matches the where clause, or null if no rows match.
*/
public async First(
options: Pick<GenerateQueryOptions<Partial<InferFromColumns<T>>>, "where">
options: Pick<GenerateQueryOptions<InferFromColumns<T>>, "where">
): Promise<InferFromColumns<T> | null> {
const statement = GenerateQuery(
QueryType.SELECT,
Expand All @@ -249,7 +249,7 @@ export class Model<T extends Record<string, ModelColumn>> {
*/
public async All(
options: Omit<
GenerateQueryOptions<Partial<InferFromColumns<T>>>,
GenerateQueryOptions<InferFromColumns<T>>,
"data" | "upsertOnlyUpdateData"
>
): Promise<D1Result<InferFromColumns<T>>> {
Expand All @@ -263,7 +263,7 @@ export class Model<T extends Record<string, ModelColumn>> {
* @param options The options for the query, see {@link GenerateQueryOptions}
*/
public async Delete(
options: Pick<GenerateQueryOptions<Partial<InferFromColumns<T>>>, "where">
options: Pick<GenerateQueryOptions<InferFromColumns<T>>, "where">
): Promise<D1Result<unknown>> {
const statement = GenerateQuery(QueryType.DELETE, this.tableName, options);
return this.D1Orm.prepare(statement.query)
Expand All @@ -276,10 +276,7 @@ export class Model<T extends Record<string, ModelColumn>> {
* @throws Throws an error if the data clause is empty.
*/
public async Update(
options: Pick<
GenerateQueryOptions<Partial<InferFromColumns<T>>>,
"where" | "data"
>
options: Pick<GenerateQueryOptions<InferFromColumns<T>>, "where" | "data">
): Promise<D1Result<unknown>> {
const statement = GenerateQuery(QueryType.UPDATE, this.tableName, options);
return this.D1Orm.prepare(statement.query)
Expand All @@ -294,7 +291,7 @@ export class Model<T extends Record<string, ModelColumn>> {
*/
public async Upsert(
options: Pick<
GenerateQueryOptions<Partial<InferFromColumns<T>>>,
GenerateQueryOptions<InferFromColumns<T>>,
"where" | "data" | "upsertOnlyUpdateData"
>
): Promise<D1Result<unknown>> {
Expand Down

0 comments on commit 30b38c7

Please sign in to comment.