Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
egarim opened this issue May 25, 2017 · 3 comments

Comments

@egarim
Copy link

egarim commented May 25, 2017

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

@reaperc9000
Copy link

@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

@lazarv
Copy link
Contributor

lazarv commented Aug 22, 2017

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.

@egarim
Copy link
Author

egarim commented Aug 22, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants