JS function with parameters and arguments as real data from database | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

JS function with parameters and arguments as real data from database

There are many examples with parameters and arguments, but I would like to see some examples where in the function definition are multiple parameters and inside the function they are used to get real data from database.

13th Jul 2019, 8:42 AM
LL1
3 Answers
+ 3
No, frontend javascript cannot interact with mongodb directly, unless there is server provides api access. You could use some of the BaaS (backend as a service) such as Firebase where there is api available for javascript to retrieve, but it's not advisable to use frontend javascript to access BaaS due to api key expose to public from browser. Anyone has the BaaS api key can update the db, even delete the whole db. You may need to learn php or Nodejs which is server javascript to access Mongodb, this is the proper why of db access from server only
13th Jul 2019, 10:48 AM
Calviղ
Calviղ - avatar
+ 2
Front end javascript cannot get any data from database directly. It need server script to read data and response to javascript whenever it request it.
13th Jul 2019, 10:29 AM
Calviղ
Calviղ - avatar
0
Yes, but if in the database, for example, MongoDB, there is entry “user_id”, then I can use a parameter in function definition as, for example, “id” and then use it in function as id.user_id, am I correct?
13th Jul 2019, 10:33 AM
LL1