Watch the actual application code and example usage.
H in a second yes so this is how the Silver Cloud looks like so I didn’t have to move a finger for this I just clicked it and it gave me the latest version of the silver Enterprise with all the Enterprise features it gave me a small cluster it automatically told me how to stop the access you can have a look at the monitoring this is what I’m not annually presented earlier so this is here I won’t show it because it’s out of scope but I will show you the connect strings and this is the connect string which I will be using there I will copy the password from here and I will switch to a cqs8 session that I have somewhere or free here okay so and I I I’m using this is the same I have been prepared so we don’t waste time but basically it’s the one of the nodes uh that was listed on the page and I’ll just connect to it I already copied the password so I have it here and I’m connected right now from my computer which is like in Czech Republic to the Silver Cloud that is in transport and I of course need to have a look at the schema so this is our schema and our table and I will first create it because without it we can really connect to the cost so the first part created the key space for me and the second part created the table for me the table is completely empty I can show it there is no data there and let’s try to play with our application so this is our application uh in application properties I already changed the properties as you saw them and I’ll just basically launch the application and get it serving the rest API
so the code compiled and it should be running just a small explanation on the application uh I am actually using Gradle Bitcoin for spring I’m using those two dependencies that I mentioned so spring web spring data for Apache Cassandra and this you can configure any way you want and I am using the jdk 17 just just because of the compatibility rewarding so the application is up and basically serving all the data I forgot to explain you the model and all these things but let’s let’s quickly go over it so this is the model so I just you see that this is symbol date value is the same as you saw in the previous part then there is the repository and the controller so the repository is here and I’m using custom prepared queries like don’t get scared this is the advanced or the customized version usually in the easy version this is fairly empty there is nothing there but because I’m overriding all the calls I just wrote the session sessions myself and I’m just using them and preparing them here or just calling them directly and this is just basically preparing the repository cost for the rest controller the queries themselves are fairly easy like if you look at the code where they are let’s expand this a little bit so if there is a builder for queries so it can help you don’t have to like write the query yourself you don’t have to write so like blah blah blah because it’s like very error prone but you can basically do it like this if you just use a query Builder you can use a select from or insert or delete from and just pass on the parameters for the relation or for basically for the columns or for values
after basically all this is done then it comes to the rest controller that I mentioned address control is fairly easy thing you just basically say what is This Server where does it listen to http calls and what are what is the mapping of the roots so there is a post route on the slash talks that is put root on this URL delete on this URL and I can show that it works so that you don’t have to believe me but this this is this is the call to get all stocks as you remember the database is empty so it will currently an empty result but I want to add to my database at all so I edit at all I want to it Microsoft and I just edit both of them and if I query database again you see that I have them here so that you believe me that it’s really there you can just look here so all the path tool was basically done from the rest API to the database itself the the application or the rest service actually runs on my computer database runs in Frankfurt and client runs on my computer but you can basically connect to the if you would expose it to internet anyone could connect there uh the other rest calls you can design your article anywhere you want for example I have a rest code that will just get me the Microsoft stock Microsoft stock and there is a different query behind it and you can you can you can basically prepare it like that
um
so let me switch to the
database here or like other other drivers like as I said I will not go through it but you will have examples here you just quickly go to these examples and play with them and switch them like this regarding the spring demo as I mentioned it is it is on the GitHub page so have a look and that is basically this custom demo what you just seen and there is a default demo so you don’t get scared and this default demo like uses the default string components it’s really really easy and I wanted to show you this because we have some time
uh the controller is similar but if you look at the repository repository is very easy so if you don’t really want to override any of the queries and you are okay with the queries out of the box from Spring it will just generate all the queries for you
and the model basically is similar like I’m having a different uh schema here for this default on purpose it’s like something simpler but if you look at it it’s it’s kind of yeah something similar it’s there’s always like some ID name description to different types but the idea the idea is basically the same as I explained so there is like the model controller and Repository in the application