Author:
Burak Inan
- We should add webFlux, r2dbc and reactive dependency of database
- The other dependencies are optional
- We should use reactive syntax to define our database in properties file
- Reactive library couldn't create schemas automatically. So that we have 2 choices;
- We can create bean in application main class. In this case;
- we should create sql file in resources and we write a query manually
- we can use serial data type for id column. Because it is create id automatically
- we will define our sql query location inside the bean
- Or we can create our table directly using DBMS
- WARNING: In both case we should be careful to use same name with entity class. Otherwise, r2dbc couldn't find the schemas and fields
- We have to import @Id annotation from springframework.data.annotation for Id field in the entity class
- Repositories should be extended to r2dbc or sub interfaces of it
- Reactive programming is still evolving. That's why we don't have every ready-made method in JPA. So it needs a good knowledge of SQL
- We can create our endpoint with 2 way;
- With Bean;
- We can create a router bean
- In this bean, we can define multiple endpoint
- Those endpoints don't use class path
- With traditional method;
- We can create separated method for each endpoint
- Those endpoints use class endpoint as we know
- https://www.youtube.com/watch?v=bXcFCgQsvAE can be watched before starting to the project. It explains logic well without database connection
- https://www.youtube.com/watch?v=3J_X1srMk3s&t=934s example with MongoDB database