Skip to content

Commit

Permalink
Chore: Model constructor, stricter types (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
Skye-31 committed Sep 17, 2022
1 parent 72da2bb commit 1e8e4e5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/spotty-mangos-hug.md
@@ -0,0 +1,5 @@
---
"d1-orm": patch
---

Chore: Make Model#constructor#columns use the provided type of the model, rather than any keys
2 changes: 1 addition & 1 deletion src/model.ts
Expand Up @@ -19,7 +19,7 @@ export class Model<T extends object> {
D1Orm: D1Orm;
tableName: string;
},
columns: Record<string, ModelColumn>
columns: Record<Extract<keyof T, string>, ModelColumn>
) {
this.#D1Orm = options.D1Orm;
this.tableName = options.tableName;
Expand Down
3 changes: 2 additions & 1 deletion typedoc.json
Expand Up @@ -16,7 +16,8 @@
"Partial": "https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype",
"Pick": "https://www.typescriptlang.org/docs/handbook/utility-types.html#picktype-keys",
"Record": "https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type",
"Omit": "https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys"
"Omit": "https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys",
"Extract": "https://www.typescriptlang.org/docs/handbook/utility-types.html#extracttype-union"
}
},
"githubPages": false,
Expand Down

0 comments on commit 1e8e4e5

Please sign in to comment.