-
fc7cb87
Thanks @Skye-31! - Feat: Allow null items in InferThis change checks NOT NULL constraints on the model definition, and allows null when the constraint is not present.
-
#44
101043b
Thanks @Skye-31! - Feat: Inferred Types!Models no longer require you to specify a definition when you create them. Instead, you can just pass in an object and the model will infer the types for you. See the following example:
import { Model, DataTypes } from "d1-orm"; import type { Infer } from "d1-orm"; const users = new Model( { tableName: "users", D1Orm: MyD1OrmInstance, }, { name: DataTypes.STRING, age: DataTypes.NUMBER, } ); type User = Infer<typeof users>; // type User = { // name: string, // age: number // }
- #41
f8ca119
Thanks @kingmesal! - Adding insert or replace
de7eb7d
Thanks @Skye-31! - Chore: Make first() return null on a D1_NORESULTS error, as it's inconsistent with local and remote, and that error is near meaningless.
- #27
1e8e4e5
Thanks @Skye-31! - Chore: Make Model#constructor#columns use the provided type of the model, rather than any keys
-
#21
b2559ef
Thanks @Skye-31! - [breaking] feat: Switch to use a QueryBuilder instead of duplicate code in the Model classThis will be much more expandable in future to support things like advanced where querying, using operators other than AND, joins, etc.
-
#26
bc18cce
Thanks @Skye-31! - Chore: Add a build testAlso ensure that the lib is built before publishing.
-
#25
1750a55
Thanks @Skye-31! - Chore: readable guides for interacting with the library Closes #22
-
7ddad51: Chore: start tests
This initially focuses on just testing Model & ORM validation, with future PRs to be focused on validation of model methods being run
- f32ff3c: Add typedoc to generate docs, see https://d1-orm.pages.dev
- 8173b4c: Chore: Readme with basic usage examples
-
3f02112: Feat: Start implementing models
This initial concept looks something like the following. The key goals for this PR are to support:
- Creating table, with a force option, and an alter table option
- Dropping tables
- First()
- All()
- Update()
- InsertOne()
- InsertMany()
- Delete()
- Upsert()
type User = { id: number, name?: string }; const Users = new Model<User>({ tableName: 'users', D1Orm: myD1Orm }, { id: { type: DataTypes.Integer, primaryKey: true, notNull: true, unique: true, autoIncrement: true }, name: { type: DataTypes.String, default: "John Doe" } }); Users.First(Options): Promise<D1Result<User>>