move to git.n39.euall books in the bag ...
This commit is contained in:
commit
8cc2662092
64 changed files with 134252 additions and 0 deletions
9
middleware/queries/checkoutBook.ts
Normal file
9
middleware/queries/checkoutBook.ts
Normal 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}';`;
|
10
middleware/queries/createBook.ts
Normal file
10
middleware/queries/createBook.ts
Normal 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}';`;
|
4
middleware/queries/deleteBook.ts
Normal file
4
middleware/queries/deleteBook.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
import { Book } from "../types/Book";
|
||||
|
||||
export const deleteBook = ({ uuid }: Pick<Book, "uuid">) =>
|
||||
`DELETE FROM bookData WHERE uuid='${uuid}';`;
|
10
middleware/queries/editBook.ts
Normal file
10
middleware/queries/editBook.ts
Normal 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}';`;
|
14
middleware/queries/findBook.ts
Normal file
14
middleware/queries/findBook.ts
Normal 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}%';`;
|
||||
};
|
7
middleware/queries/getBook.ts
Normal file
7
middleware/queries/getBook.ts
Normal 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}';`;
|
8
middleware/queries/index.ts
Normal file
8
middleware/queries/index.ts
Normal 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";
|
1
middleware/queries/listBooks.ts
Normal file
1
middleware/queries/listBooks.ts
Normal file
|
@ -0,0 +1 @@
|
|||
export const listBooks = `SELECT * FROM bookData ORDER BY title`;
|
4
middleware/queries/returnBook.ts
Normal file
4
middleware/queries/returnBook.ts
Normal 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}';`;
|
Loading…
Add table
Add a link
Reference in a new issue