How can I do that?
To start with, planning to save it into the HTML5 local database using IndexedDB? May be later on I can save it the user's table in the database.
Is this the right approach?
if they will be using the search on multiple devices save it on the server side. that way they get their complete search history. if not go with local.
do not forget to have a mechanism to purge the search queries on a user action.
Indexeddb is not design for that kind of usage. It is better of with usual http caching.
Indexeddb is design for storing full table and query client side itself.
Related
Im coding a static page app using Angular, which shows various Instagram and Twitter posts of the company, and shows the details of the members. I have few questions regarding this, and would like any help.
Firstly, I have about 100+ contacts to display on the first page. Should I create a Json by myself and retrieve it from the service, or should I create a backend and save it there ? I do not have any backend as of now.
Other thing, I was able to retrieve Instagram Json with media content using their API, the doubt im facing is, once I have the call done, will the Json change automatically when the user adds/edits their posts? Or will the Json be the same as I first called it with? Any help is appreciated. Thanks.
For your case, as you have fewer data using Firebase is the best approach. If you write a backend and maintaining it would cost you more. You can use Firebase service URL to retire those records. In future, if you want to add more data it would be easy.My suggestion is Firebase.
Should I create a Json by myself and retrieve it from the service, or should I create a backend and save it there ?
Are you revealing credentials or other sensitive information in the client? That would be one reason to have a backend apart from Instagram or Twitter. Do you envision exhausting API rate limits of Instagram or Twitter APIs? That would be another reason; you could cache results in your backend to reduce external API traffic. Do you need to process (reduce? translate?) the data before it gets to the client, or are you satisfied with performing any processing on the client (e.g. is it fast enough)?
TL;DR: It depends a lot on your particular requirements.
If you do want a backend, the recommendation in the answer from #praneeth-reddy to use Firebase is excellent. If you only need processing/transformation but no caching or separate storage, then AWS Lambda may also be worth considering. If you need more control (build vs. buy), you could write your own backend.
...will the Json change automatically when the user adds/edits their posts? Or will the Json be the same as I first called it with?
Angular can help you update content automatically if the client side data (think browser JavaScript memory) changes via its automatic change detection functionality, but you would have to provide your own logic (e.g. in Angular services perhaps leveraging RxJS) to update the client side data based on data from the APIs. You could poll to update periodically, or for better performance listen for changes using an asynchronous event/push mechanism such as websockets or streams.
I am using Angular2 & Auth0 to Authenticate a user.
Currently, according to their "best-practice" , the user profile is saved to localStorage , and once you need to pull information, take it from there.
This sounds like a bad practice to me, is there a better way to keep logged in profile for local query (name, photo etc.)? maybe using an Angular2 service?
The problem is if you want to keep the user profile for later use (if the user close the window and reopen it later) without having to make request to a server. Then you need to store it somewhere.
And storage facilities in the browser are quite limited: IndexedDB for database storage with query capabilities, indexes, etc, localStorage for simple key=>value storage,or even cookie for a limited amount of data as plain-text.
but if you don't need the data for a later use, you can keep it in memory (in a service, for example).
You can also combine both in-memory and offline-storage in a service.
You can combine both ways.
Storing it in localstorage to get that infos without request them anytime and wrapping a Service around it to not address the storage from everywhere.
I am dsigning an app for iOS using phonegap. What I want to do is log down the date and time each time when the user pressed a button on the screen, and be able to view the log on device screen with an admin access. I know I have to create some sort of a database to store the info, but can someone give me an example on how to create one as I'm new to phonegap and not sure how to do that.
In my opinion the best SQLite Plugin for saving a lot of data is this plugin:
https://github.com/brodysoft/Cordova-SQLitePlugin
There is no limit of storing. In this post How to compact SQL instructions in Cordova? I have written how to compact SQLite instructions, so you have not all this event overload.
But do you really want save every tap? That will be a lot of scripting work.
It seems as localStorage would be sufficient for your problem. You can simlply Json.stringify your data and put it to the local storage. Later get it from there and json.parse it. No phonegap needed just pure html5. Try search for localstorage HTM5
So currently i'm buidling a local website within work.
one of the feature that needs to be built is a request submission form.
We originally had this email to a central mailbox but we want it to take the form data and save it to a database in this case Access.
Is there any possible way of doing this without using SQL or ASP ? As the website is being build on a local server for all members of staff to access.
In the end all I want to do is create a form the user can submit which is sent to a database. Is it possible or would it be better to stick with the email idea?
It is not possible to save data without a database server. Only thing can be done is cookies in javascript but these will not be available always and will never help you cause..
First of all I would like to say that html/css is client side scripting language, without using server side language you can't save anything. You can use php or javascript(ajax) in order to do that.
Unless you are targeting Safari browsers, you can try using IndexedDB(http://caniuse.com/#feat=indexeddb), a form of local storage supported by major browsers, with no size limit. It can be used carefully to emulate a remote database using a JavaScript object relational mapper.
I strongly suggest you a server :). If you don't want to use sql there are many ways to save data. The simplest would be to write a file on disk with what you need.
Only under Internet Explorer, you can save data into MS Access database for example using ActiveX. But html file must be open locally.
Edit:
If needed I can write you a sample code.
I am using Google Map API to do address translation(mainly by geocoder).
And I'd like to store results into local database for future use since google map has a limit on total query number and frequency.
But how? I have googled and found an ActiveX based solution. Is there platform independent alternatives?
To access a database you are going to need a server side language. JavaScript can talk to PHP through AJAX and PHP can update the database with whatever parameters you give to it via JavaScript.
I would stay away from ActiveX as it can be tricky and you just dont need it.
When you have a database setup, have a look at these websites
http://www.tizag.com/mysqlTutorial/mysqlinsert.php
http://api.jquery.com/jQuery.ajax/
Current in-browser database options include IndexedDB, Web SQL, and Web Storage.
Browser support, however, isn't all that good. Web Storage is your best bet, but it won't work on IE7 and earlier.