Back

Handling database requests

  • 0
  • Web
  • Cloud
larkx
11 Oct, 2023, 14:22

I'm not disputing the use of user cookies for authentication

TL;DR
The user is asking about handling database requests and whether they should use separate functions or one function for different queries. The response states that it depends on their specific needs and use case. They also discuss the possibility of clogging up GitHub with multiple repositories. There is no specific solution provided in the thread.
D5
11 Oct, 2023, 14:23

Then what's the issue? πŸ˜…

D5
11 Oct, 2023, 14:24

If you mean setting permissions, as said previously, you should use a function

D5
11 Oct, 2023, 14:26

If that's the issue, yes, you can prevent people from creating documents by only giving read permissio

D5
11 Oct, 2023, 14:27

Respect calls to a function, they're rate limited by default, but you could implement custom rate limits inside the function if you need even more strict limits.

larkx
11 Oct, 2023, 14:49

I will yeah

larkx
11 Oct, 2023, 14:50

I presume functions requests to database completely override any permissions, like a super-user?

larkx
11 Oct, 2023, 14:50

Which means I can remove the user create permission?

D5
11 Oct, 2023, 15:10

Yes, you need to set an API key in the function so they override permissions obviously

D5
11 Oct, 2023, 15:10

Yes

D5
11 Oct, 2023, 15:10

You only set permissions for the user to execute the function and nothing else

D5
11 Oct, 2023, 15:10

Apart from read permission

larkx
12 Oct, 2023, 13:55

@D5 Just a quick question, I might've already asked it but for my functions, what's the best conventions to use? For example, should I:

  1. Create a separate cloud function for creating documents, editing documents and deleting documents.
  2. Create one cloud function for all database queries.

And additionally, should I be setting up the functions just as the create document function works with the Appwrite API or, should I make it case-specific (e.g: have a function called "Create Memo" and only have arguments like "content" and "colour".

D5
12 Oct, 2023, 13:57
  1. Yes
  2. This depends on your needs

This latest ones depends on your use case too and preferences, but most times I prefer having separate/custom functions for each thing

larkx
12 Oct, 2023, 14:00

I just didn’t want to clog up my github with a bunch of repos but i guess we’ll see

larkx
12 Oct, 2023, 14:01

In my case, the functions would all relate to the same database and collection

D5
12 Oct, 2023, 14:03

Of course you could handle everything with 1, but I think some cases it's not the most convenient approach mainly from a performance perspective. Also you don't need to use GitHub for functions.

As said, this is a bit complex topic since it depends more on your use case and specific needs

D5
12 Oct, 2023, 14:04

Maybe in your case it's 100% fine using the same function. If you're going to do the same or almost the same kind of thing or requests, but for example, with different parameters, then you will be fine with 1. However if you're going to do multiple and different things, then it's better multiple

larkx
12 Oct, 2023, 14:10

Ah okay, in the simplest form, I will be creating memos, editing them and deleting them. So perhaps one function may work.

larkx
12 Oct, 2023, 14:10

what’s the alternative to using GitHub?

D5
12 Oct, 2023, 14:16

Yes, or just 3 will be enough, that's your choice πŸ˜„

D5
12 Oct, 2023, 14:17

There will be just a very little difference, probably unnoticeable if handled properly

D5
12 Oct, 2023, 17:09

Cli deployment

larkx
12 Oct, 2023, 21:58

πŸ‘

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