Hi
You can't directly access the database via javascript, so you would need an API writing - the backend code does all the accessing of data with the database, and provides an end point that you javascript can send data to (and receive data from).
I've written a few APIs. I mostly use codeigniter.
I'd have to know how complex your API needs to be before I can give you a proper quote, but if its just a handful of operations, then this quote should be good.
Thanks a lot,
John