Back

[Solved] Validating a vote system with appwrite /nosql?

  • 0
  • General
  • Functions
  • Databases
  • Users
ireneus
23 Oct, 2023, 20:32

This might be off-topic I hope you guys could help me with this I have a thread and I want to validate it by user upvotes kinda like yt how would I validate, assuming it's a function that has a list of users? and what is the right way to query the number of votes

TL;DR
The user is asking for a solution to validate a vote system using Appwrite and NoSQL. In the thread, it is mentioned that Appwrite currently doesn't support aggregation functions. However, the suggested solution is to create atomic counter fields for each question/answer/votable post. This involves creating a collection for posts and another collection for votes. A function should then be created to trigger whenever there is a change in the votes collection. The function should increase the value of the posts.votes attribute when a document is added and decrease it when a document is deleted. This way, counters can be maintained without the need to query all the
Binyamin
24 Oct, 2023, 00:57

As of now, Appwrite's doesn't support any aggregation function, you can follow (and upvote it <a:agooglethumbsup:635256484682530825>) this issue to track it.

As for your solution, the best would be to create an atomic counter fields for each of the questions/answers/votable posts.

Like so, for example, in case of posts.

  1. Create collection named posts with this attributes.
  • title
  • content
  • votes
  1. Create collection named votes with this attributes.
  • user_id
  • post_id
  1. Then create a function and make it to be triggered on any change to the votes collection, so when the a documents is being add increase the value of posts.votes attribute, and when it got deleted decrease it.

This way you can have counters without having the need to query all the documents every time.

ireneus
24 Oct, 2023, 12:06

I see tyvm

ireneus
24 Oct, 2023, 12:06

[Answered] Validating a vote system with appwrite /nosql?

ireneus
24 Oct, 2023, 12:07

[Solved] Validating a vote system with appwrite /nosql?

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