From 59de642d3191612003d1a31872087a78f664ee62 Mon Sep 17 00:00:00 2001 From: Endeavorance Date: Thu, 2 Jan 2025 10:28:12 -0500 Subject: [PATCH] 1.2.0 --- package.json | 2 +- src/index.ts | 10 +--------- src/table.ts | 6 ------ src/wrapped-row.ts | 26 -------------------------- test/wrapped-row.ts | 43 ------------------------------------------- tsconfig.json | 1 + 6 files changed, 3 insertions(+), 85 deletions(-) delete mode 100644 src/wrapped-row.ts delete mode 100644 test/wrapped-row.ts diff --git a/package.json b/package.json index 8a51e09..3bc44b4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@endeavorance/prequel", - "version": "1.1.0", + "version": "1.2.0", "exports": "./dist/index.js", "types": "./dist/index.d.ts", "scripts": { diff --git a/src/index.ts b/src/index.ts index 1112126..9ca531c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,13 +1,5 @@ import type { Column, ColumnShorthand, DataType } from "./columns"; -import { WrappedRow } from "./wrapped-row"; import { Prequel } from "./prequel"; import { Table } from "./table"; -export { - Prequel, - Table, - WrappedRow, - type DataType, - type Column, - type ColumnShorthand, -}; +export { Prequel, Table, type DataType, type Column, type ColumnShorthand }; diff --git a/src/table.ts b/src/table.ts index a17316e..8c5abe3 100644 --- a/src/table.ts +++ b/src/table.ts @@ -7,7 +7,6 @@ import { } from "./columns"; import { SchemaError } from "./error"; import { Prequel } from "./prequel"; -import type { WrappedRow } from "./wrapped-row"; export type ExtractRowShape = T extends Table ? R : never; @@ -499,11 +498,6 @@ export class Table { return res.count; } - public save(wrapped: WrappedRow) { - const row = wrapped.unwrap(); - this.update(row); - } - public toString() { return `"${this._name}"`; } diff --git a/src/wrapped-row.ts b/src/wrapped-row.ts deleted file mode 100644 index d093710..0000000 --- a/src/wrapped-row.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Represents an instance of a row in a table of a database. - * Wraps the raw Row data and provides methods for interacting with it. - */ -export class WrappedRow { - protected row: RowShape; - - constructor(row: RowShape) { - this.row = row; - } - - /** - * @returns The row data as a JSON string. - */ - toJSON(): string { - return JSON.stringify(this.row); - } - - /** - * Exports the raw row data. - * @returns The raw row data. - */ - unwrap(): RowShape { - return this.row; - } -} diff --git a/test/wrapped-row.ts b/test/wrapped-row.ts deleted file mode 100644 index f92d621..0000000 --- a/test/wrapped-row.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { Database } from "bun:sqlite"; -import { expect, test } from "bun:test"; -import { WrappedRow, Table } from "../src/index"; - -interface User { - id: number; - name: string; -} - -const db = new Database(); -const table = new Table(db, "Users", { - id: { - type: "INTEGER", - primary: true, - }, - name: "TEXT", -}); - -class UserWrappedRow extends WrappedRow { - get name(): string { - return this.row.name; - } - - set name(val: string) { - this.row.name = val; - } -} - -test("setting values on an WrappedRow", () => { - table.insert({ - id: 1, - name: "Alice", - }); - - const alice = table.findOneByIdOrFail(1); - const inst = new UserWrappedRow(alice); - - inst.name = "Bob"; - table.save(inst); - - const bob = table.findOneByIdOrFail(1); - expect(bob.name).toEqual("Bob"); -}); diff --git a/tsconfig.json b/tsconfig.json index 9eb9fac..f5fdd89 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -25,4 +25,5 @@ "noPropertyAccessFromIndexSignature": false, "noUncheckedIndexedAccess": true }, + "include": ["src"] }