Back

Using queries on partial date

  • 0
  • Databases
  • React Native
  • Cloud
RawViper
27 Nov, 2024, 17:17

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);

TypeScript
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); } }`

TL;DR
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.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more