Back

[SOLVED] How should I save a instore wallet in Appwrite

  • 1
  • Self Hosted
  • Accounts
  • Databases
  • Users
Binyamin
20 Jun, 2023, 13:41

For your use-case I'll create collection that no user has reading access, and each user will get reading access to is own.

That means no one get writing access.

So, all the writing access gonna be through a function.

TL;DR
Summary: The user is asking how to save an in-store wallet in Appwrite. The solution suggested is to create two collections - one for Wallets and one for Transactions. The Wallets collection will have wallet_id and user_id fields, while the Transactions collection will have wallet_id and amount fields. The wallet value will be the sum of all the transactions documents. It is recommended to protect the database and use server-side logic for security. The suggestion is to use functions for writing access and restrict reading access to each user's own collection. Using nodejs instead of functions is also an option.
Binyamin
20 Jun, 2023, 13:42

Is this make sense?

Hexi
20 Jun, 2023, 13:42

yeah but I can use nodejs instead of functions right or would you recommend against that?

Binyamin
20 Jun, 2023, 13:43

You mean access node-appwrite using your nodejs project?

Hexi
20 Jun, 2023, 13:44

Yup

Binyamin
20 Jun, 2023, 13:44

That will great.

Binyamin
20 Jun, 2023, 13:44

I've suggested function because the is most-common

Binyamin
20 Jun, 2023, 13:44

But any server side logic is good

Hexi
20 Jun, 2023, 13:44

alright and how would I for instance store it?

Hexi
20 Jun, 2023, 13:45

just a integer or is there something that is more "secure" that you know of

Binyamin
20 Jun, 2023, 13:45

Mmm, You mean in case someone gained access to your database?

Hexi
20 Jun, 2023, 13:45

yeah

Binyamin
20 Jun, 2023, 13:46

I think at the end even banks use Integer (float) for the amount value.

Binyamin
20 Jun, 2023, 13:46

I don't think putting it behind some secret-logic will make it more secure.

Hexi
20 Jun, 2023, 13:46

Hmm yeah prob I am overthinking it

Binyamin
20 Jun, 2023, 13:46

Just make sure to protect the database.

Hexi
20 Jun, 2023, 13:47

Yeah that wouldnt be too hard

Binyamin
20 Jun, 2023, 13:47

Like, I assume that if someone got access to your Appwrite, then the attacker will grab or change other stuff.

Binyamin
20 Jun, 2023, 13:47

It's a right way of tackling it Let me check something.

Binyamin
20 Jun, 2023, 13:55

From what I see in that topic The best logic be like that, You'll have two collections

The Wallets collection that will simply have

  • wallet_id
  • user_id

Then the Transactions collection that will have

  • wallet_id
  • amount (minus or plus)

And the wallet value will be the sum of all the transactions documents, So in start you'll give each user for example plus transaction with 100

Hexi
20 Jun, 2023, 13:56

Oh yeah thats way smarter to calculate the transactions then just store it as a integer

Binyamin
20 Jun, 2023, 13:56

Of course you can add more attributes to the trabnsaction table so it easy to track

Hexi
20 Jun, 2023, 13:56

Yeah

Hexi
20 Jun, 2023, 13:56

Thanks!

Hexi
20 Jun, 2023, 13:57

[SOLVED] How should I save a instore wallet in Appwrite

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