Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to store javascript in a database?

I have an idea for a web application where a user can submit Javascript code that can then be served up to other users. I'm wondering what's the best way of going about this. Is it possible to store the Javascript in a database and then serve it up to users as they request it? I would also like to be able to attach metadata to each piece of code: name, user ratings, etc., so a database seems like the natural solution to my somewhat underinformed mind. I'm looking at using Rails on the backend with MongoDB.

like image 408
lobati Avatar asked Jun 30 '10 02:06

lobati


People also ask

Can JavaScript use a database?

JavaScript is a client-side language that runs in the browser and MySQL is a server-side technology that runs on the server. You need to use the server-side language Node. js to connect to the MySQL Database.

Where do I store JavaScript?

JavaScript in <head> or <body> You can place any number of scripts in an HTML document. Scripts can be placed in the <body> , or in the <head> section of an HTML page, or in both.

Where should I store JavaScript in HTML?

JavaScript in body or head: Scripts can be placed inside the body or the head section of an HTML page or inside both head and body. JavaScript in head: A JavaScript function is placed inside the head section of an HTML page and the function is invoked when a button is clicked.


1 Answers

Javascript is a string of text. Databases can store strings of text. Hence, databases can store Javascript.

Unless you have some specific idea I'm missing though, I wholly agree with @Aircule's sentiment.

Wow, I don't think I've seen a worse idea in ages.

like image 85
deceze Avatar answered Oct 11 '22 23:10

deceze