nighthawkcoders / teacher_portfolio

GitHub Pages / Jupyter Notebook guides for Python, Java, JavaScript, Linux
https://nighthawkcoders.github.io/teacher_portfolio/
Apache License 2.0
1 stars 50 forks source link

Spring POST methods and Database definitions #54

Open jm1021 opened 8 months ago

jm1021 commented 8 months ago

Owners

P1 Kaiden, Vishnu, Vardaan, Jishnu, Derrick, Nikhil P3 Orlando, Mati, Shreyas, Shivansh, Quinn, Aaron, Haoxuan

Background

POST methods and Database definitions. Establish basic frontend/backend API methods to support Login/Signup. Create an anatomy lesson and drawings that explain how the frontend/backend work, including explaining the security config. Use materials from the Teacher Portfolio for the Person database. At the conclusion of this lesson, students should have a working Login/Signup system

Methods

REST endpoints will have similarity from application to application. In planning APIs, for a Users system you can anticipate key methods. The Users RESTful APIs would likely contain these endpoints.

Once a RESTful API receives and processes an HTTP request, it will return an HTTP response. Included in this response is an HTTP status code. Common status codes are shown.

Database definition

Database definitions for User Profile exists in materials. Many of the API have existed before.

To add something beyond would be to incorporate some ideas together. JSONB allows for the storage of nested and dynamic data structures. In the context of Person object stats, it means that each person can store activity data with the formatted date as the key, and the structure of this JSON data can be modified in FE without without altering the database schema.

Storing HashMaps with jsonb

JSONB is a binary representation of JSON data. It is a data type used in some relational databases (such as SQL databases) to store JSON documents in a more efficient and flexible way compared to traditional JSON. Within SQL databases, this data from the JSON can often be filtered, searched and/or extracted using provided functions.

@JdbcTypeCode(SqlTypes.JSON)
@Column(columnDefinition = "jsonb")
private Map<String,Map<String, Object>> stats = new HashMap<>(); 

View the way POJO is structured for the person sqlite.db table. After definition define POJO, JPA and full complement of CRUD methods, you would have a very flexible data structure that would work with many different types projects. Include JSONB and Roles data in response of User data in GET, POST APIs.

jm1021 commented 8 months ago

[