Rank 3: Container
Hello,
please what's the best way to count document for a Particular user,
USE CASE
A user created a post, and i would want to count the number of posts that user has made since he joined the platform
but here is my code, i'm not too confident on it, and i would love your ideal about what to do
My Controller
userPostCounter({required uid}) async {
final document = await _postApi.userPostCounter(uid: uid);
final data = document.map((post) => PostModel.fromMap(post.data)).toList();
var counter = 0;
if (data.isNotEmpty) {
counter = data.length;
}
return counter;
}```
**My PostApi**
``` @override
Future<List<Document>> userPostCounter({required String uid}) async {
DocumentList doc;
doc = await _db.listDocuments(
databaseId: Common.dataBasesId,
collectionId: Common.postCollection,
queries: [
Query.equal('quickPosting', true),
Query.equal('uid', uid),
Query.isNull('repliedTo'),
],
);
return doc.documents;
}```
*Please, i'm i on the right track on this?*