Skip to content

Latest commit

 

History

History
245 lines (146 loc) · 9.92 KB

CHANGELOG.md

File metadata and controls

245 lines (146 loc) · 9.92 KB

d1-orm

0.9.2

Patch Changes

0.9.1

Patch Changes

  • #78 9a49134 Thanks @Skye-31! - Fix(deps): move vitest to dev dependency

    Vitest was accidentally installed as a dependency, rather than a devDependency. Closes #77

0.9.0

Minor Changes

  • #71 5c168e9 Thanks @dtbuchholz! - This introduces breaking changes by updating to the latest @cloudflare/workers-types@^4.20231025.0, including compatability changes for the D1Database exec API. Namely, the model methods CreateTable and DropTable now return a D1ExecResult instead of D1Result.

0.8.0

Minor Changes

  • #69 2d5cbef Thanks @helloimalastair! - Adds a withRowId option to the Model class, defaulting to false. When not set to true, the Model.createTableDefinition will now include a WITHOUT ROWID line, which can optimise the performance of a majority of tables.

0.7.2

Patch Changes

  • #61 921aef0 Thanks @Skye-31! - Chore: use single quotes in the create table definition of a model

0.7.1

Patch Changes

  • 30b38c7 Thanks @Skye-31! - Fix: Unnecessary double partial in some Model queries

0.7.0

Minor Changes

  • #57 75f58c0 Thanks @Skye-31! - Feat: Make new Model() option for ORM optional. Add Model.D1Orm getter & Model.SetOrm() to allow people to provide an orm after the constructor has been initialised

0.6.0

Minor Changes

  • #55 5e30824 Thanks @Skye-31! - [breaking] Feat: Refactor models to allow multiple unique keys

    This change restructures the way that primary keys, auto increment keys and unique keys are provided. This allows for multiple unique keys to be provided for a model. These fields have been moved from the ModelColumn type to the first parameter in the Model constructor.

    Refer to the docs for more information.

0.5.5

Patch Changes

  • fc7cb87 Thanks @Skye-31! - Feat: Allow null items in Infer

    This change checks NOT NULL constraints on the model definition, and allows null when the constraint is not present.

0.5.4

Patch Changes

  • b8e1ce6 Thanks @Skye-31! - Chore: fix inferred return type for Model.First()

0.5.3

Patch Changes

  • 5d09207 Thanks @Skye-31! - Chore: export some types used by Model so VSC can pick up on them

0.5.2

Patch Changes

0.5.1

Patch Changes

  • 926d8c6 Thanks @Skye-31! - Chore: fix Model return types for First() and All()

0.5.0

Minor Changes

  • #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
    // }

0.4.0

Minor Changes

0.3.3

Patch Changes

0.3.2

Patch Changes

  • 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.

0.3.1

Patch Changes

0.3.0

Minor Changes

Patch Changes

0.2.2

Patch Changes

  • b0088b2 Thanks @Skye-31! - Fix types for Model.First() (should return T, not D1Result)

0.2.1

Patch Changes

  • #27 1e8e4e5 Thanks @Skye-31! - Chore: Make Model#constructor#columns use the provided type of the model, rather than any keys

0.2.0

Minor Changes

  • #21 b2559ef Thanks @Skye-31! - [breaking] feat: Switch to use a QueryBuilder instead of duplicate code in the Model class

    This will be much more expandable in future to support things like advanced where querying, using operators other than AND, joins, etc.

Patch Changes

  • #26 bc18cce Thanks @Skye-31! - Chore: Add a build test

    Also ensure that the lib is built before publishing.

  • #25 1750a55 Thanks @Skye-31! - Chore: readable guides for interacting with the library Closes #22

0.1.3

Patch Changes

  • 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

0.1.2

Patch Changes

0.1.1

Patch Changes

  • 8173b4c: Chore: Readme with basic usage examples

0.1.0

Minor Changes

  • 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>>