This Ember-cli addon is an attempt to make ember-data work with an odata api.
The addon provides an OdataAdapter
that extends the ember-data RESTAdapter
and an OdataSerializer
that extends the RESTSerializer
.
Tested with ember-data v2.3.0
npm install
this repository
The OdataAdapter
configures ember-data to work with the oData api.
Currently supported adapter methods:
store.findAll()
can be used to retrieve all of the records for a given type.
store.findAll('post'); // => GET /posts
store.findRecord()
can be used to retrieve a record by its type and ID.
store.findRecord('post', 1); // => GET /posts(1)
store.query()
provides the ability to query for records that meet certain criteria. The query parameters will be appended to the url as query string parameters.
For example, query for all post
records by the Author
with the name of Peter
.
store.query('post', { $filter: "Author/Name eq Peter" }}); // => GET /posts?$filter=Author/Name eq Peter
store.queryRecord()
behaves the same asstore.query()
store.queryRecord('post', { $filter: "Author/Name eq Peter" }}); // => GET /posts?$filter=Author/Name eq Peter
model.save()
will produce aPUT
(MERGE) request.
NOTE: when attempting a PUT
request, the adapter will intercept the request,
change the method verb to POST
, and set a X-HTTP-Method
header with a value
of MERGE
. The If-Match
header is also added with a value of *
.
When performing a MERGE
request, only the model attributes that have changed are
sent in the request.
model.save(); // => MERGE /posts(1)
POST
and DELETE
have not been implemented or tested yet.
The OdataSerializer
normailzes, serializes, and de-serializes data from the
oData api to be consumed by ember-data.
-
HasMany
relationships are supported. -
BelongsTo
relationships have not been implemented or tested yet.
git clone
this repositorynpm install
bower install
ember server
- Visit your app at http://localhost:4200.
ember test
ember test --server
ember build
For more information on using ember-cli, visit http://www.ember-cli.com/.