Accessing database from public (.js) file

Hi,

I have created a general.js file under /public folder. This file stores general functions which need to be accessed from multiple pages. One of the function needs to access a database to enter the details of a newly signed up member.

Can anyone please tell me how to access database in /public/general.js file.

Thanks,
Sety.