Back

Intercept document creation

  • 0
  • Functions
Brave
22 May, 2023, 08:35

When I setup a function that gets called by a document.create does this function intercept the creation of the document and I have to create it myself with the given payload or how does that work?

TL;DR
Summary: The user is asking about document creation and whether functions can intercept the creation process. They discuss the possibility of functions being triggered automatically or manually, as well as the benefits of using separate functions. The user also asks about the speed of standalone functions compared to embedding the code in every function. Finally, they ask if functions can intercept document creation and create the document with a given payload. Solution: No, functions do not intercept the creation of a document. Functions are triggered after the document has been successfully created. If you want to prevent direct document creation, you can use a function where the user passes the data to create the document.
Vedsaga
22 May, 2023, 08:43

nope, function doesn't intercept, function get trigger once doc successfully get created...

Vedsaga
22 May, 2023, 08:44

yap, if you want to prevent user from creating Doc directly, you can use the function where user pass the Data

Brave
22 May, 2023, 08:44

That’s bad πŸ˜… It would be soooo easy

Brave
22 May, 2023, 08:45

Yeah that’s exactly what I don’t want to do haha

Vedsaga
22 May, 2023, 08:45

I mean, yaa but as Function act as Serverless so in that sense it's not possible...

Brave
22 May, 2023, 08:45

Yeah makes sense 🫠

Vedsaga
22 May, 2023, 08:45

can understand but, for security is concern so that's ideal approach

Brave
22 May, 2023, 08:46

Oke thx πŸ™πŸ» Have a nice day!

Vedsaga
22 May, 2023, 08:47

no prob you too πŸ™‚

Brave
22 May, 2023, 09:12

Oh another quick question πŸ˜… Do you think it’s faster to make standalone functions for stuff I need to check on every execution or should I just paste this code in every function?

Brave
22 May, 2023, 09:12

Hope you understand what I mean

Vedsaga
22 May, 2023, 09:26

it's generally idea to have seperate function, not just that it will faster ( I mean relative faster not compareabily) , but also another reason to have smaller function is to seperate area of concern

Vedsaga
22 May, 2023, 09:26

so, if one function have bug another function still will work and user don't have to wait for issue for that function to be fixed

Brave
22 May, 2023, 09:27

True

Brave
22 May, 2023, 09:27

Will the functions automatically get called locally? Or can I force this somehow?

Vedsaga
22 May, 2023, 09:28

it have both behaviour, it can be called manually via SDK or automatically trigger whenever new action happen such as document creation, new user regsitation etc...

Vedsaga
22 May, 2023, 09:29

it's upto you how you would like func to work

Brave
22 May, 2023, 09:30

I mean if I trigger func 1 from my client and then func 2 gets triggered from inside func 1. Does func 2 gets automatically called locally?

Vedsaga
22 May, 2023, 09:31

oh yaap

Vedsaga
22 May, 2023, 09:32

one function can call another function internally*

Brave
22 May, 2023, 09:33

Okay and this happens automatically? So it does not do the round trip over the external api endpoint?

Vedsaga
22 May, 2023, 09:33

yap it happen internally, round trip nope it doesn't

Brave
22 May, 2023, 09:33

πŸ‘πŸ»

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