+ 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.
3 ответов
+ 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
+ 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.
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?