mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 15:05:35 +00:00
feat: add a search modal using the database (wip)
This commit is contained in:
17
app/controllers/searches_controller.ts
Normal file
17
app/controllers/searches_controller.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import type { HttpContext } from '@adonisjs/core/http';
|
||||
import db from '@adonisjs/lucid/services/db';
|
||||
|
||||
export default class SearchesController {
|
||||
async search({ request, auth }: HttpContext) {
|
||||
const term = request.qs()?.term;
|
||||
if (!term) {
|
||||
return console.warn('qs term null');
|
||||
}
|
||||
|
||||
const { rows } = await db.rawQuery('SELECT * FROM search_text(?, ?)', [
|
||||
term,
|
||||
auth.user!.id,
|
||||
]);
|
||||
return { results: rows };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user