IBM Worklight JSON Store with Sync using HTTP Adapter - ibm-mobilefirst

How to load data from database on load of the application?
How to push data to database?
The sample given by IBM Worklight helps to load data from JSON store, but how to use HTTP Adapter to fetch data and load?

Read the documentation and look at the JSONStore getting started modules and code samples.
How to load data from database on load of the application?
Use load. You can also do it with WL.Client.invokeProcedure or jQuery.ajax and then call add with the response data.
How to push data to database?
Use push or get the documents with local-only changes with getPushRequired and use WL.Client.invokeProcedure or jQuery.ajax to send data back to the backend.
All the methods linked above have examples. You should be able to figure out how to adapt those examples to your needs.

Related

how to access external data sources such as MySQL instead of webpages?

I am a novice at Etheuerm. I want to know how to access external data sources such as MySQL or excel through chainlink instead of webpages
33sir
Welcome to the amazing Ethereum world :)
Chainlink is a flexible framework that can retrieve data from any API and connect with existing systems.
I like the examples that the Chainlink website present when you scroll down, how to get weather data or sports data, for example. It is connecting with API in the external world.
So in you case, you need to create an API to connect with your data sources, like MySQL or excel.
Here you can get more info how to call any external API
It is not necessary a webpage, but you will make a GET request to a service that you will create.

Creating a REST api to send data to the frontend

I was thinking about some projects that I could do, and I came with the idea of building a books app in React native. To start, I wanted the user to get a list of all the books and the ability to get the details about each book and some other things. But I'm completely new on the backend, and my doubt is:
Should i use the features of the backend, such as a database or should I just create a simple serve that only sends a JSON to the frontend?
You should use a database as it is more flexible and easier to manage, and using any backend framework to forward your data in json format to your frontend, I would suggest mysql server and slim php framework

Basic iOS Networking Questions

I am trying to do my first App which is a basic joke app that uses tableViews and allows users to add their own jokes to the app database. My problem is in the networking department and I think I'm getting confused with all that is out there. I have a couple basic questions that I was hoping to get answers or opinions on:
I am really confused about the path that is taken from the app on the iphone to the database that is holding the data. Does the tableview controller call a AFNetworking object, that then sends a JSON object to a server-side script(??), that then queries a SQL database and returns the data? I am just looking for a basic path that allows the user to add their own joke to the database.
Is this a URL request? When I see URL request I think of a web page.
I have a website that is hosted on GoDaddy.com. Is this also sufficient to hold the database for the jokes on the iOS app?
I have been searching for days and have gotten no simple answer. I just want to study the correct subjects instead of wasting time. ANY help or pointers would be appreciated.
You have two forms of storage here - some form of web store (such as a server database technology like MySQL) and the local iOS CoreData (if you want to store locally, or make a new request every time thus requiring a connection). You can use web requests (perhaps using the AFNetworking library) to ensure that the local store and the online store match. A typical flow could be for example - on app launch perform a GET request to pull all jokes from the server using a service URL that returns a JSON file, then update Coredata. To upload a new joke, use a POST request which performs a similar function.
A 'URL request' maps to a web technology which uses some form of logic to determine how to return some data. For example, the request may arrive at a web server (such as Apache) which routes your request to a PHP controller file which then talks with the database and returns your data.
GoDaddy is a hosting platform that supports PHP and MySQL (amongst other technologies that will do the same trick), so yes.
In your situation, I would study the Model-View-Controller design pattern. Your app will be a great learning experience I think, you should pick up a lot of core concepts.
EDIT to answer your question in the first comment:
Your question:
1. Are JSON files stored on the device or the server? 2. Does JSON replace JavaScript?
Answers:
JSON is short for JavaScript Object Notation, it's just a way of representing data and doesn't replace anything. It's particularly useful because most languages support parsing JSON in a way that the technology understands. It's a handy way of sending data around because it's pretty lightweight and is widely supported.
In a case like this, the JSON would probably not be stored on the server. The data would be stored in a database. Your request will be mapped to a server side technology such as PHP or Ruby which will then ask the database for the information, convert it to JSON for sending and return it to the client. (It is possible to store data on a server in a JSON file, but you would have to write your server side code to manipulate the JSON file directly, it would be hard work and way less elegant!)
The client (in this case an iOS device) will parse the JSON into an object that Objective-C can play with, like an NSDictionary.
Hope that helps!

How do you store data remotely in an iOS app?

I have an app that relies on some key value pairs where the value could change at a point in the future due to 3rd party api. The app is only useful when connected to the internet by the way. If any values change I don't want issue a new version of the app - I would rather that these values were pulled from a webservice/static xml file on my server. I would only need to pull these if I encountered an error.
Is there a standard way to do this or should I just roll my own?
EDIT: I'm not so interested in a server side technology - I think a flat file will suffice. What I'm interested in is what format should the flat file should be and how to cache it into my application once I get an error.
try redis, high-performance key-value store. used by some of the big cloud players, like cloudfoundry. Have a look at http://redis.io/. Objective-c client is available at http://redis.io/clients.
I figured out the best way for my use scenario:
I setup a json file on S3 which required authentication. I then used AWS for Objective C to authenticate so I could access that file.
I decided that I only needed to update the local info when the applicationDidBecomeActive in the App Delegate. I then got the json async and on success I then checked a version number in the json and if outdated wrote the changes to NSUSerDefaults (which are then used through the app.) If there was an error getting the json file I just continued as I would already have the previous set of NSUserDefaults that would do the job until the user next made the app active.
This solution worked best for me as it's simple to maintain and should easily handle the load even if my app were popular.
Have you considered using iCloud? It has support for key value pairs. More info here: http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/iCloud/iCloud.html

What is best Way to store data locally on iphone?

I am designing a web app that fetches data every time a user logs into his/her account. The data is an xml file containing image links and some text. I want this data (after image fetch/load from the actual link) to be stored locally so that every time an user opens the app it doesn't have to load everything from scratch. Locally stored contents should load first, then in the background some network processing shall be done so that the newer data is automatically updated. For storing the data I am planning to use SQLite but is there any other efficient way other than this to do the same ?
How does facebook app do this kind of stuff ? Thank you so much
The Facebook app is not really a web app but rather a native Cocoa Touch app.
If you are really creating a web app, your only option is to use localstorage and fetching new data asynchronously using XMLHTTPRequest.
If – on the other hand – your app is a native app, you’ll most likely want to use Core Data for storage and get incremental updates in a separate thread (or using libdispatch in case you’re only targetting post 4.0 devices) using a separate managed object context which you can then merge to the main thread using mergeChangesFromContextDidSaveNotification:.