add upload and search implemented
This commit is contained in:
1 parent
f3007d6419
commit
3aeffb3585
3 files changed
+71
-23
No files matched your search
+11
-2
@@ -37,12 +37,21 @@ export async function createCar(carData: Omit<Car, 'id' | 'createdAt'>) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getCars() {
|
||||
export async function getCars(searchQuery?: string) {
|
||||
try {
|
||||
const queries = [Query.orderDesc('$createdAt')];
|
||||
|
||||
if (searchQuery) {
|
||||
const searchTerm = searchQuery.toLowerCase();
|
||||
queries.push(
|
||||
Query.search('title', searchTerm)
|
||||
);
|
||||
}
|
||||
|
||||
const response = await databases.listDocuments(
|
||||
config.databaseId!,
|
||||
config.carId!,
|
||||
[Query.orderDesc('$createdAt')]
|
||||
queries
|
||||
);
|
||||
return response.documents;
|
||||
} catch (error) {
|
||||
|
||||
Reference in new issue
Block a user