Add column presets
This commit is contained in:
parent
6479d09196
commit
1bfc20673d
6 changed files with 50 additions and 34 deletions
|
@ -1,6 +1,6 @@
|
|||
import { Database } from "bun:sqlite";
|
||||
import { expect, test } from "bun:test";
|
||||
import { Prequel, Table } from "../src/index";
|
||||
import { ColumnOf, Prequel, Table } from "../src/index";
|
||||
|
||||
interface UserWithID {
|
||||
user_id: number;
|
||||
|
@ -263,11 +263,11 @@ test(".delete() deletes a full record", () => {
|
|||
table.insertPartial({ name: "Kate" });
|
||||
table.insertPartial({ name: "Sayid" });
|
||||
|
||||
expect(table.size()).toBe(3);
|
||||
expect(table.count()).toBe(3);
|
||||
|
||||
table.delete(table.findOneByIdOrFail(2));
|
||||
|
||||
expect(table.size()).toBe(2);
|
||||
expect(table.count()).toBe(2);
|
||||
|
||||
expect(table.findAll()).toEqual([
|
||||
{ user_id: 1, name: "Jack" },
|
||||
|
@ -281,11 +281,11 @@ test(".deleteById() deletes the element with the given primary value", () => {
|
|||
table.insertPartial({ name: "Kate" });
|
||||
table.insertPartial({ name: "Sayid" });
|
||||
|
||||
expect(table.size()).toBe(3);
|
||||
expect(table.count()).toBe(3);
|
||||
|
||||
table.deleteById(2);
|
||||
|
||||
expect(table.size()).toBe(2);
|
||||
expect(table.count()).toBe(2);
|
||||
|
||||
expect(table.findAll()).toEqual([
|
||||
{ user_id: 1, name: "Jack" },
|
||||
|
@ -299,11 +299,11 @@ test(".deleteWhere() deletes all rows that match", () => {
|
|||
table.insertPartial({ name: "Jack" });
|
||||
table.insertPartial({ name: "Sayid" });
|
||||
|
||||
expect(table.size()).toBe(3);
|
||||
expect(table.count()).toBe(3);
|
||||
|
||||
table.deleteWhere({ name: "Jack" });
|
||||
|
||||
expect(table.size()).toBe(1);
|
||||
expect(table.count()).toBe(1);
|
||||
|
||||
expect(table.findAll()).toEqual([{ user_id: 3, name: "Sayid" }]);
|
||||
});
|
||||
|
@ -336,7 +336,7 @@ test(".deleteById() respects when references are set to cascade", () => {
|
|||
});
|
||||
|
||||
users.deleteById(user.user_id);
|
||||
expect(posts.size()).toBe(0);
|
||||
expect(posts.count()).toBe(0);
|
||||
});
|
||||
|
||||
test(".deleteAll() deletes all rows in the table", () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue