RawViperOriginal post
Web Developer
Hello,
I need to get documents from Database that start with "2024-11" but it's not returning anything.
Here current used for this query
`export async function searchLogbookByDate(
query: string,
// eslint-disable-next-line prettier/prettier
userId: number
) {
try {
let queryArray;
queryArray = [
Query.startsWith("date", query),
Query.equal("userId", userId),
];
console.log("date query", queryArray);
queryArray as unknown as Query[];
const posts = await databases.listDocuments(
databaseId,
logbookCollectionId,
// eslint-disable-next-line prettier/prettier
queryArray as unknown as string[]
);
console.log(
query,
// eslint-disable-next-line prettier/prettier
"Posts in search logbook by date" + JSON.stringify(posts)
);
if (query === null) throw new Error("Something went wrong");
if (!posts) throw new Error("Something went wrong");
return posts.documents;
} catch (error: any) {
Alert.alert("Error", error.message);
}
}`
Summary
Developers are having trouble getting documents from the Database that start with "2024-11" using a specific query. The current query is not returning anything. The issue might be related to how the query is structured. Make sure the query is correctly formatted to search for partial dates.