n39librarian/middleware/queries/findBook.ts

15 lines
376 B
TypeScript
Raw Permalink Normal View History

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}%';`;
};