1.1.0
This commit is contained in:
parent
13c3d86a10
commit
20ac2da081
6 changed files with 47 additions and 10 deletions
|
@ -138,6 +138,22 @@ test(".insertPartial() inserts a partial row", () => {
|
|||
});
|
||||
});
|
||||
|
||||
test(".insertWithout() inserts a partial row with type safety", () => {
|
||||
const table = makeTestTable();
|
||||
table.insertWithout<"user_id">({
|
||||
name: "Jack",
|
||||
});
|
||||
|
||||
const lookup = table.db.prepare<UserWithID, string>(
|
||||
`SELECT * FROM ${table} WHERE name = ?`,
|
||||
);
|
||||
const found = lookup.get("Jack");
|
||||
expect(found).toEqual({
|
||||
user_id: 1,
|
||||
name: "Jack",
|
||||
});
|
||||
});
|
||||
|
||||
test(".count() gets the current number of rows in the table", () => {
|
||||
const table = makeTestTable();
|
||||
table.insertPartial({ name: "Jack" });
|
||||
|
@ -167,6 +183,12 @@ test(".findAll() returns the full table", () => {
|
|||
expect(allUsers[2]).toEqual({ user_id: 3, name: "Sayid" });
|
||||
});
|
||||
|
||||
test(".query() returns a prepared statement for the table", () => {
|
||||
const table = makeTestTable();
|
||||
const query = table.query("SELECT * FROM Users WHERE name = ?");
|
||||
expect(query).toBeDefined();
|
||||
});
|
||||
|
||||
test(".findOneWhere() returns a row based on basic criteria", () => {
|
||||
const table = makeTestTable();
|
||||
table.insertPartial({ name: "Jack" });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue