Well, if you read the latest messages on this group, you'll see I had
a lot of trouble myself...
However, it all comes down to understanding how the persistence plugin
works and why we sometimes need custom adapters.
Agility is based on jQuery, and all the actions performed by the rest
adapter are simply wrappers for jQuery's Ajax function.
The standard ajax call with jQuery looks like this:
$.ajax({
url: [ your rest service URL here],
type: ["GET" for getting data, POST for adding, PUT for updating or
DELETE],
dataType: [json, xml, html...],
and other opcional parameters...
});
The built in persistente plugin assumes that the REST service you are
connecting to has an URL with the form "baseUrl/api/collectionName".
So if you write your own restful API in the server, and you want to
use persistence out of the box, you must create your urls this way.
For example, if you have a collection of people, your API should look
like this:
GET: /api/people (this returns all the persons in your people
collection).
GET: /api/people/id (this returns the person with the given id).
etc... (Look at Agility's docs where this is explained clearly).
However, sometimes you have to connect to a third party API, one
designed by someone else, whose URL doesn't fit this format.
In this case, you must write a custom adapter. The adapter is
responsible for modifying the parameters to the above Ajax call in
order to make it work.
If you look this same thread, I needed to write an adapter for
connecting to a mongolab database. This API had some specific
requirements.
For example, the URL should contain an API key at the end, so I
modified the adapter to get the API key from a parameter passed to
persistence, which is added at the end of the URL.
Any other modification needed to make persistence work with your
database should be done in your adapter.
The built-in adapter works only if your API's URL has the form
baseUrl / api / collection name.
If this is not the case, then a custom adapter is needed.
I hope this clerared up some stuff for you...
Luis