Reputation: 2176
Can Breeze js be used just on client side with server only supporting REST? The reason is I want to take advantage of Breeze's client side data retrieval and management and Server side is already fully developed.
Upvotes: 1
Views: 1101
Reputation: 17052
Yes, with the caveats that you will still need to supply Breeze metadata either on the client or the server, and of course, you will not be able to use any of the EntityQuery.methods like 'where', 'take', 'skip', 'orderBy' etc. The Breeze samples include an "Edmunds" sample that talks to an arbitrary REST api. Excerpted here:
var serviceName = "http://api.edmunds.com/v1/api/"; // edmunds
var ds = new breeze.DataService({
serviceName: serviceName,
hasServerMetadata: false,
useJsonp: true,
jsonResultsAdapter: jsonResultsAdapter
});
var entityManager = new breeze.EntityManager({dataService: ds});
var q = EntityQuery.from("vehicle/makerepository");
// this will call -> "http://api.edmunds.com/v1/api/vehicle/makeRespository"
myEntityManager.executeQuery(q).then(...);
You can also use the EntityQuery.withParameters method if your API supports parameters (in additon to or instead of 'pure' REST). i.e. something like:
var makeId = "Ford xxx";
// will send (approx) -> "http://api.edmunds.com/v1/api/vehicle/modelRespositoryfindByMakeId?makeId=Ford xxx"
var query = breeze.EntityQuery
.from("vehicle/modelrepository/findbymakeid")
.withParameter( { makeId: makeId };
If you are going either of these routes, please see the Breeze documentation on Metadata and the JsonResultsAdapter as well. ( and look at the Edmunds sample).
Hope this helps.
Upvotes: 2