odata-v4-server icon indicating copy to clipboard operation
odata-v4-server copied to clipboard

how to turn the generic implementation into specific mysql , mongo or postgress setup

Open egarim opened this issue 7 years ago • 3 comments

Hi i have been able to setup the odata server for postgres using the following repository

https://github.com/jaystack/odata-v4-server-pgsql-example

the repository contains the source with all needed references to connect to postgres serve a model, now I wonder, how can you start from the scratch with just the odata-v4-server and add the correct connectors to connect to an specific database.

can you provide an example to achieve my goal? to turn the generic version of the server and the turn it into a postgres , mongo or mysql odata server

egarim avatar May 25 '17 10:05 egarim

@egarim : I am not a contributor to this repo. But I have a similar use case to yours. You should take a look at odata-v4-pg and odata-v4-sql packages. It is used to parse odata syntax and generate the sql queries.. You can very well use that as a template to derive your custom logic. FYI - All the magic happens in visitor.ts

reaperc9000 avatar Jun 18 '17 07:06 reaperc9000

Hi @egarim, odata-v4-server is a platform independent generic OData server and you can implement any business logic in the controllers. Connectors are specific OData query compilers, which are transforming the OData query AST to the specific platform query. As @silasjohn correctly aligned you in the right direction, each connector magic is in the connector's visitor.ts file. It is walking the AST tree's nodes and builds the final SQL or mongodb query during the process. You can use an existing connector (as you can see in the pg, mysql, and mssql connectors extending the original odata-v4-sql visitor) or create a new one from scratch. So finally, do the platform specific or custom logic in your ODataController implementation. Connectors are just helpers to use the OData query AST easier.

lazarv avatar Aug 22 '17 08:08 lazarv

thanks I was just retaking this projects this is a great input

On Tue, Aug 22, 2017 at 11:12 AM, Viktor Lázár [email protected] wrote:

Hi @egarim https://github.com/egarim, odata-v4-server is a platform independent generic OData server and you can implement any business logic in the controllers. Connectors are specific OData query compilers, which are transforming the OData query AST to the specific platform query. As @silasjohn https://github.com/silasjohn correctly aligned you in the right direction, each connector magic is in the connector's visitor.ts file. It is walking the AST tree's nodes and builds the final SQL or mongodb query during the process. You can use an existing connector (as you can see in the pg, mysql, and mssql connectors extending the original odata-v4-sql visitor) or create a new one from scratch. So finally, do the platform specific or custom logic in your ODataController implementation. Connectors are just helpers to use the OData query AST easier.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jaystack/odata-v4-server/issues/13#issuecomment-323952487, or mute the thread https://github.com/notifications/unsubscribe-auth/ACu2pJK7DhgYoYqwgBCvL7hQiFKD2rUWks5sao1ZgaJpZM4NmOM7 .

-- Regards Jose Manuel Ojeda

Our sites Xamarin Android Apps http://www.xamarin-android-apps.com Xamarin iOS Apps http://www.xamarin-ios-apps.com Xamarin Forms Apps http://www.xamarin-forms-apps.com

Skype:Jose.Manuel.Ojeda GoogleTalk:[email protected] Cellphone: 503 79235612 QQ:2492739188

egarim avatar Aug 22 '17 10:08 egarim