Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to wire SailsJS to BreezeJS

I'm looking at using Sailsjs for server side processing and validation and angular on the client side. Apparently BreezeJS supports Odata and WebApi for its interaction with the datasource. I know that Sails provides a REST Api out of the box.

How would I go about setting up Sails to provide either OData or WebApi to connectivity for Breeze?

Also, is there any other well known way of connecting Sails to Angular that provides the ability to generate queries on the client side that then get executed on the server? (My use case is filtering large datasets and manipulating the result on the client before batch updating the datasource)

Thanks!

like image 556
danba Avatar asked Nov 11 '22 12:11

danba


1 Answers

What database and/or ORM are you using? That affects the answer, because the OData query must be turned into the appropriate query for your ORM/database. One of the following might work for you:

  • The breeze.server.node repo includes an OData parser that turns OData URLs into expression trees. Then there are adapters that turn these expression trees into MongoDB queries or Sequelize queries. If you are using MongoDB or Sequelize, this might be what you need. You can write your own adapter for Waterline if none exists yet.

  • The breeze.js.labs repo includes breeze.ajaxrestinterceptor.js which converts Breeze's OData URLs into REST-style resource URLs. It only supports a subset of the possible URLs, and will need to be adapted to your own API conventions.

  • An upcoming Breeze release will offer an alternative to OData: an all-JSON query language, inspired by the MongoDB and Sequelize query languages. This will make it easier to write your own backend, and to support Sails/Waterline in the future.

like image 198
Steve Schmitt Avatar answered Nov 15 '22 10:11

Steve Schmitt