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
- CORS error only on tables db api After u...
I've recently updated my self hosted appwrite instance to the 1.8.0 and updated my frontend with the tables db apis but strangely, even if I'm able to log in, g...
- Bug: When creating a table, table name i...
I created a table with a typo. my_taable .... then my code couldn't find it. i updated table name and still couldn't find it. the table name doesn't update. i h...
- unexpected row_invalid_structure error
In images you can see both my code,error, column schema I do have timezone in table schema but still while creating a row i am receving row_invalid_structure e...