move to git.n39.euall books in the bag ...

This commit is contained in:
0ry5 2024-09-09 20:41:15 +02:00
commit 8cc2662092
64 changed files with 134252 additions and 0 deletions

View file

@ -0,0 +1,9 @@
import { Book } from "../types/Book";
export const checkoutBook = ({
checkoutBy,
uuid,
contact,
lastCheckoutDate,
}: Pick<Book, "uuid" | "lastCheckoutDate" | "checkoutBy" | "contact">) =>
`UPDATE bookData SET lastCheckoutDate='${lastCheckoutDate}', checkoutBy='${checkoutBy}', contact='${contact}' WHERE uuid='${uuid}';`;

View file

@ -0,0 +1,10 @@
import { Book } from "../types/Book";
export const createBook = ({
uuid,
title,
isbn,
shelf,
published,
}: Pick<Book, "uuid" | "title" | "isbn" | "shelf" | "published">) =>
`INSERT INTO bookData SET uuid = '${uuid}', title = '${title}', isbn = '${isbn}', shelf = '${shelf}', published = '${published}';`;

View file

@ -0,0 +1,4 @@
import { Book } from "../types/Book";
export const deleteBook = ({ uuid }: Pick<Book, "uuid">) =>
`DELETE FROM bookData WHERE uuid='${uuid}';`;

View file

@ -0,0 +1,10 @@
import { Book } from "../types/Book";
export const editBook = ({
uuid,
isbn,
title,
published,
shelf,
}: Pick<Book, "uuid" | "isbn" | "title" | "published" | "shelf">) =>
`UPDATE bookData SET shelf='${shelf}', isbn='${isbn}', title='${title}', published='${published}' WHERE uuid='${uuid}';`;

View file

@ -0,0 +1,14 @@
import { Book } from "../types/Book";
import { getBook } from "./getBook";
export const findBook = ({
uuid,
isbn,
title,
}: Pick<Partial<Book>, "uuid" | "title" | "isbn">) => {
return !!uuid
? getBook({ uuid })
: title
? `SELECT * FROM bookData WHERE title LIKE '%${title.toLowerCase()}%';`
: `SELECT * FROM bookData WHERE isbn LIKE '%${isbn}%';`;
};

View file

@ -0,0 +1,7 @@
import { Book } from "../types/Book";
/**
* sql query to find a book by uuid
*/
export const getBook = ({ uuid }: Pick<Book, "uuid">) =>
`SELECT * FROM bookData WHERE uuid = '${uuid}';`;

View file

@ -0,0 +1,8 @@
export { returnBook } from "./returnBook";
export { getBook } from "./getBook";
export { checkoutBook } from "./checkoutBook";
export { listBooks } from "./listBooks";
export { findBook } from "./findBook";
export { createBook } from "./createBook";
export { deleteBook } from "./deleteBook";
export { editBook } from "./editBook";

View file

@ -0,0 +1 @@
export const listBooks = `SELECT * FROM bookData ORDER BY title`;

View file

@ -0,0 +1,4 @@
import { Book } from "../types/Book";
export const returnBook = ({ uuid }: Pick<Book, "uuid">) =>
`UPDATE bookData SET checkoutBy = NULL, contact = NULL WHERE uuid='${uuid}';`;