For example I have gender attribute in my collection. And then, I am going to get the total documents of male gender documents. What I want is that it returns me a number only. Like, I do not want in my client side to get the total length of documents. What I want that is in server side it will get the numbers of total documents and send this to client side.
For anything that need to do things that are not available with the Database SDK then I will use functions to achieve it. So in your case this is an example of how it work for you in JavaScript
module.exports = async function (req, res) {
let total = 0;
try {
const res = await database.listDocuments('db', 'collections', [
sdk.Query.equal('gender', MALE),
]);
total = res.total;
} catch (e) {
}
res.json({total: total});
};
I've omitted all Appwrite preparing code
If this is didn't what you've meant lmn
I see thank you sir
Recommended threads
- Seed db
hello there... is this correct way to seed appwrite
- Query Appwrite
Hello, I have a question regarding Queries in Appwrite. If I have a string "YYYY-MM", how can I query the $createdAt column to match this filter?
- Apple OAuth Scopes
Hi Hi, I've configured sign in with apple and this is the response i'm getting from apple once i've signed in. I cant find anywhere I set scopes. I remember se...