tora
tora

Reputation: 31

Creating a database to use with JavaScript

I want to create a database to hold images, then have the images pulled out of the database into an array.

Every ten minutes or so I want the new images to replace the old images in the array.

I will be using JavaScript to update the webpage every 10 minutes based on the user's clock.

Should I store the images in MySQL, or in a different database that is more JavaScript friendly?

Upvotes: 2

Views: 5309

Answers (5)

NonzeroCornet34
NonzeroCornet34

Reputation: 21

This is new, but that's basically the entire purpose of SimpleDB (https://sdbapi.jdbdu.xyz/). It consists of only three commands, so you need like zero database experience in order to use it. Hope this helps.

Upvotes: 1

machineghost
machineghost

Reputation: 35790

CouchDB is VERY Javascript friendly; in fact, if you use CouchApp, you can use pure CouchDB to run your entire site; no need for a Python/Ruby/Node.js/whatever layer! I definitely recommend it if you're looking for a "pure JS" database.

Oh, and I should mention that Couch uses HTTP as it's access mechanism, so you can totally put records in/get records out of it using basic AJAX :-D

Upvotes: 1

Matthew Cox
Matthew Cox

Reputation: 13672

About the only way to interact with a database from javascript is to use a server-side intermediary such as perl, php, python, asp.net, java, etc...

Generally, you would write a web service on the server side that performs the desired database interaction. You then invoke this web service from javascript code.

If you need data back from the server then Json or Xml is the usual method of information exchange.

Upvotes: 1

Demian Brecht
Demian Brecht

Reputation: 21368

Images should be stored on the file system and paths to the images should be stored in the database. This SO question has a good detailed answer as to why. MySQL works just fine for storing the paths. However, Javascript itself has no way to communicate directly with the database - you'll need to have an intermediate served file (php, python, etc) that will expose the functionality that you're looking for. You can tap into this using Javascript (AJAX).

Upvotes: 1

JavaScript in the browser has no way of interacting with SQL databases directly. If you want to use one, you'll need to write an interface for it on the server (in Python, PHP or something).

If you could avoid using a database (as just use files on a server), it would be simpler. Just the image files, with JSON files for metadata, might be appropriate for some uses.

Upvotes: 1

Related Questions