fix fuzzy search result - to be array as well

This commit is contained in:
Dobromir Popov
2024-02-27 02:44:58 +02:00
parent 5bc7d1ad22
commit af4923ba20
5 changed files with 17 additions and 11 deletions

View File

@ -118,7 +118,7 @@ exports.getPrismaClient = function getPrismaClient() {
logger.debug("getPrismaClient: process.env.DATABASE_URL = ", process.env.DATABASE_URL);
prisma = new PrismaClient({
// Optional: Enable logging
// log: ['query', 'info', 'warn', 'error'],
log: ['query', 'info', 'warn', 'error'],
datasources: { db: { url: process.env.DATABASE_URL } },
});
}

View File

@ -66,7 +66,7 @@ async function findPublisher(names, email, select, getAll = false) {
if (result.length === 0 && names) {
console.log("No publisher found, trying fuzzy search for '" + names + "'- email: '" + email + "'");
const publishers = await prisma.publisher.findMany();
result = await common.fuzzySearch(publishers, names, 0.90);
result = [await common.fuzzySearch(publishers, names, 0.90)];
console.log("Fuzzy search result: " + result?.firstName + " " + result?.lastName + " - " + result?.email);
}
//always return an array