Handling server database in client-side with JavaScript