#how i can set a limit for users with a specific label to create a maximum number of documents?

15 messages · Page 1 of 1 (latest)

jovial cosmos
#

Just like many apps have premium vs free users, and free users can use the app but with some limitations; i wanna implement something similar. in my app, the premium users have a label and the free don't. My plan is that, each free user can create maximum of 4 posts in a bucket, where the premium users can create as many as they want.
So i would need a variable in the DB, that no user can update. I also need to implement this checking if any user is creating more documents then that limit number

I could check the db for how many documents the user have already created, before creating each post. but this doesn't sound the perfect way to handle it, also not much secure. Can you think of any way to implement this feature securely within appwrite?

dusk dragon
tardy galleon
#

how can you know how the user exceeds more than 4 uploads in a bucket, propably a function the triggers on bucket create and checks if the user has exceeded his? (int attribute limitation)

#

but then again the check needs to happen before uploading in the bucket

jovial cosmos
#

in this case, I need to count how many documents the user has before/after each creation. is there any easier way? I'm wondering if I should maintain another collection only for this limit value, where the doc ID will be the user ID, and that collection will have nothing but the Read permission to the users. so by reading that, I can show the user an indicator on the client side. and about updating it, I might create a function with create and delete events, so that the function can update that value. what do you think about this approach?

#

but in both of the approaches, just like @tardy galleon mentioned, how are we gonna prevent the user from uploading files

dusk dragon
dusk dragon
#

yes obviously count

jovial cosmos
# dusk dragon sure

which one will be more efficient u think? counting total documents on each doc creation/deletion? or maintaining a different collection?

dusk dragon
jovial cosmos