2

I am working on an assignment for a dummy phonebook app, which is an "extra points" part of a test for a local frontend job opening. I did some basic apps with angular before, but I always used it along with php and mysql. For this project the requirements state that I can't communicate with a server, so I need to store, edit, delete and search through data without a real database.

I don't even know what options are out there to achieve something like that, neither which one should I choose. I am looking for a simplest tool that could help me achieve those requirements, preferably one that has decent documentation that can help me get up and running as soon as possible.

4 Answers4

2

You can use simple local filesystem and store objects as JSON using JSON.stringify() and parse them back using JSON.parse(jsonstring)

to write phonebook to your server's file

var phonebook = {
    'name1' : 234283409,
    'name2' : 234253453,
    'name3' : 234234236
};

var jsonStr = JSON.stringify(phonebook);

/*
__________________
contents of jsonStr

{"name1":234283409,"name2":234253453,"name3":234234236}
__________________
write a logic here to save this JSON on a file in your server.
*/

to read phonebook to your server's file

//write a logic here to read JSON back from your server's file
var jsonStr = getJSONDataFromServer();

var phonebook = JSON.parse(jsonStr);

//now you can use your phonebook as a usual js object
Raman Sahasi
  • 30,180
  • 9
  • 58
  • 71
1

You can use csv file to store your data.

1

To store data on the client you can use any local storage methods:

  • WebStorage: Web Storage API (provides both sessionStorage and localStorage)
  • gears: Google Gears-based persistent storage
  • whatwg db: HTML database storage standard
  • cookie: Cookie-based persistent storage RFC

The best choice depends on the kind of data you need to store, and the usage of that data. The most common choice is WebStorage.

If you use Angular, the great module ngStorage is available, that makes Web Storage working in the Angular Way.

Be warned that:

  • you'll be able to store only data per user, of course (i.e., you'll not be able to store any global status of the application).
  • any client storage solution poses strict space limits, which often differ from browser to browser.

If instead you simply don't want to use any local server solution, you could try some cloud platform, like, for example, firebase (just acquired by Google), or others.

Community
  • 1
  • 1
MarcoS
  • 17,323
  • 24
  • 96
  • 174
  • Thanks a lot, I started working on it using ngStorage, but I am wondering will all of the functionality I need be possible with this approach. I will need to add an id key to every contact, and I'll need an option to display and edit each of the contacts in a separate view based on their id, and I will also need an option to search for specific names or numbers. – DigitalSoulArts Jul 25 '16 at 18:42
  • If you need to add an uniq id key to every contact, you really need a server side backend... :-) Please read about firebase... – MarcoS Jul 26 '16 at 07:05
0

you can use Google's Firebase. If firebase is complicated to you then use simple localstorage.

Rohit Bind
  • 113
  • 6