Is it possible to create an information bank in JavaScript?

6

How can I create a simple database without using a server? I think the answer would be no, but check the following:

  • I'm at work and I do not have access to databases or servers. This way I can work only on the local network and shared folders.

  • I can not connect USB to the machine and I'm not an admin on my computer.

  • The information I need to store is few and simple, without the need to use a database.

  • People who will make changes or additions to this information are a work team, with no possibility of simultaneous editing.
  • Not everyone can edit the code through the editor, therefore looking for other ways to include information on the page.

The idea would be to create a simple form in IE8, as I have access only to it.

  • HTML : It has two forms one for insert and one that receives information
  • Button : "Save" This executes a documento1.js that identifies the fields entered and saves the fields to any extension.

What I have:

  • I can store the information entered in a .js file among others by means of JavaScript.
  • I can save the file as documento2.js , giving a var to each field entered, so I can identify the fields later.
  • The documento2.js loads in head of HTML, then any update in the document giving an F5 HTML will have access.

What I'm missing :
I need the form that will return results to automatically recognize the fields in documento2.js .

<td name="recebe" id="Campo01">
(aqui o codigo que preciso para trazer um resultado que esteja no documento2.js com a identificação "Campo01") 
</td>

* If necessary I could change the file extension to save the information, I only need HTML to reload this file in head and populate some fields as the data in this file.

Or is there a less complicated solution to work saving information off?

    
asked by anonymous 29.08.2014 / 18:41

3 answers

4

Short answer: No!

Developing a bit more: Depends on your needs. A DBMS is a powerful tool to persist your data. Bor this the name BANK, your data is stored and protected and when you need them they can be accessed quickly and effectively. Saving data to files even works if you do not have a lot of data or complexity in the information.

Javascript is something that is running in the browser, so all information stays on the client unless you do some kind of upload of that data. In real-world applications, there is little point in collecting user data that you, on the server side, will not have access to.

Finally, there are "cloud" technologies that might be useful to you and take a good look at node.js.

Edit 2 I still do not understand it entirely because you want to save information offline but this PuchDB mentioned in the comment seems interesting (I did not know it) so you can read "over the top" it works by synchronizing data typed offline when the page comes back online. But then it looks like it needs CounchDB (which in turn runs on an Apache server) but it's worth a look when I have more time.

As for your need to save small pieces of data offline you should probably use cookies! But there goes a path that I do not usually tread (my business is more dealing with large corporate applications online)

    
29.08.2014 / 19:35
9

It is inadvisable to use the file system itself on a network drive for data that potentially will be changed by two or more people concurrently. The ideal is to use a mini webserver for this. For this solution to apply, there is a prerequisite though:

Does your company's firewall allow one computer to access another via port 80? (or other unused port)

If the answer is "yes", here's what I suggest:

  • Use a lightweight, portable database such as SQLite. Using this database as a client-server is complicated, and in your case does not justify the effort. Therefore, a single process (the mini webserver) must connect to this bank, do not release access to it via the network drive . In the end, the entire bank will be contained in a single file, which you can safely move to wherever needed, back up, etc.
  • Develop your application in a mini-webserver, also portable, that is simple to install and configure. What technology to use, depends on your expertise, but as an example I will mention two that I have already used in practice, with success:
    • Jaminid (Java Mini Daemon), using HSQLDB (pure Java database, with option to keep the tables in memory). This project is dead (it has not been updated since 2006) but it should still work. Good if you have experience with Java, and access to a JVM in your environment (because nothing else is necessary to install).
    • Django. If you have Python in your environment, you can run Django in simplified mode without the need for an external webserver. It integrates well with SQLite.
  • Put your mini-webserver to work on your computer, and have the other computers on your network access it through your IP and custom port, if necessary. So everyone will read and write in the same bank, without any competition problems.

The technologies I've mentioned are two that I have personally used and confirm that they are feasible, but there are many others (such as node.js, for example). Probably many even easier to use. Look for "portable web server" and you will find many options ( example , example ).

    
29.08.2014 / 19:31
0

Dear, after a few hours I was able to develop a simple code in javascript.

I do not know if it really is functional, but it corresponds to what I need.

1 - It works like this: HTML has an input that receives what the client types, and a "p" that will receive the information later.

2 - The javascript captures what the client types and with a save button creates an example.js file with an "x" function and the information I need there, this file is stored in the network folder.

3 - HTML opens the file example.js by HEAD and the function "x" in onLoad by BODY, the function "x" causes the "p" to receive the information stored in example.js. >

I will edit later to be more understandable, as I have to leave.

    
29.08.2014 / 21:42