Project using Java Spring Boot and MongoDB NoSQL Database

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
foreign and finally the Java project is here that's right I know you are waiting for this from a long time so basically after watching gojava after watching spring framework there was one question right what next how do you build a project and that's where I have a small project for you so basically we'll do this project together using spring Boot and we are going to use a database as well for data storage right and for this project we are going to use mongodb now why spring boot why mongodb will discuss that bit later and also we need a front end right and for front end we are going to use react now basically in this project we are not going to build the right application let's say we already have the UI ready now we have to work on the backend part so the backend part will be done with the help of spring Boot and the database will be mongodb even before looking at the project there is one particular question in your mind and that is is it a good time to watch this video maybe you don't know springboard maybe you don't know mongodb how will you understand this project so I am making this video considering two situation the first one is what if you know spring Boot and mongodb the basics you are at the right places because you understand how will you use your knowledge of springboard and build an application and also if you know mongodb Basics you will know how to use the mongodb cloud which is atlas now what if you don't know this Technologies and that's the beauty now I'm making sure that when I'm explaining you the concepts at least you will understand the flow of a project you'll understand why I'm doing certain things and why exactly that line of code but yeah if you are if you want to do it by yourself after watching the videos that's where you will get stuck but of course there is different way of learning stuff sometimes you have to learn from the basics and sometimes you have to come from top to bottom okay this is what you can do in the project and now let me learn the basics so it doesn't matter at what stage you are you can enjoy this session now let me talk about the project which we're going to build so the project is actually very simple this is a project basically we are building our platform for someone to get a job and what if someone want to hire someone so basically this portal or this website is good for both the employer and for the job Seeker let's say you're a job seeker and you are looking for a job I know this is a very basic UI but again as I mentioned right the idea of this video is not to understand the UI part the main thing is the back end so I wanted some UI so we have it here and you will find this entire project the UI the back end in the description so you will get a GitHub link and you you can access the project and you can run on your machine okay so you don't have to type everything by yourself don't worry okay so let me click on this get job now so basically I'm looking for a job and these are all the job descriptions which I have so these people are looking for candidates who know so let's say if I talk about the first one they're looking for developer and basically they're looking for software engineer okay I've just typed the description the way I want it it doesn't matter you know the grammar is not may not be perfect the technology might not match we're just here to learn right so let's go with that so we got some description looking for software engineer who can work with spring Boot and mongodb and react okay you are watching the right project then uh the experience required is one year it should be year by then that's fine uh these are the skill set required in terms of Technology uh then we have the same profile let's say if you go scroll down uh we also have Junior data scientist uh spelling mistake here but you can ignore uh so data scientist who has end-to-end project experience that's great 12 years I'm not even sure if data science is that old but anyway it's my data I can do whatever I want with that okay so skill set required Python numpy and those stuff okay so this looks cool right and also we have an uh requirement for editor uh who knows Final Cut Pro and you can use my Mac Studio uh the actual editor is not using it so I'm looking for someone else okay doesn't matter so let's say these are the profiles we have here and now let's say if I have a lot of job requirements let's say one thousand or ten thousand how do I search for my specific requirement of course you can use a search box here so in this search box of course you can particular profile let's say I want to search for developer so I can type developer here okay and it should give me the results so it is giving me all the results of developers you can say developer developer developer developer here but what if I'm not sure what profile I need but I'm sure that I know something example let's say I'm not I know threads so I can simply type I know threads and you can see it will find a profile where the skill set is threads okay so basically we are also able to search and that's exciting right because we are implementing a search feature and trust me if you do it by yourself using a Java code or any programming language it is very time consuming and we have to write a lot of lines of code so we'll understand how do we do this using the mongodb atlas so here let's say if I want to search for maybe I'm looking for a job only in Mumbai so I can type Mumbai you can say it will give you the jobs which in the description where Mumbai is mentioned so basically for sure when you search for something we are not just searching in a profile so let's say this is a profile here this is a description this is the number of years of experience required and these are the Technologies you should know so basically we are not just searching in the profile we are also switching for the description and the technology okay maybe it's like more of a Google search which we are trying to build it will be quite awesome right and also what if you want to hire someone maybe if we want to post a new job so let's say in my office I need a requirement of a blockchain developer so I can click on higher talent and let's say job profile I would say blockchain developer and number of experience required is to let's say description person should be familiar with ethereum developer who knows how to make dabs that's it and then the requirement is let's say the person should know JavaScript anyway we don't have a option of solidity here but again I wanted to keep it light so we got JavaScript there you can change the UI the way you want it's all about the submission which you do for the server so when I click on submit and if I search for let's say blockchain developer now is it there it should be okay let me refresh so you can see if I go back to this page if I go back to get job now we have a requirement for blockchain developer cool right and if I search for dab okay you can see we got the developer here okay so this is what we want to build now for this of course the react app is ready so I will show you the code a bit but will not be writing the record by yourself but we it will be requiring a spring boot so we are going to build this with spring Boot and we are going to use mongodb in the back end so let's get started so we'll minimize this screen I don't want this and in fact I wanted to show you the vs code so this is basically the the react project which we have so you can see we have multiple files here this is for the form this is for the feeds what you see all the developers all the job posting and you can say the request is getting sent to the server again if you don't want to use react in the front end you can you can use normal uh UI as well or even if you don't want to touch the UI part I'm not a big fan of UI by the way we can use the apis calling maybe you can use Postman to test these apis or we can use Swagger okay so we'll use all those things in this project I know it's quite exciting so let's get started okay so what we'll do is first of all let's create a project from scratch now what are the Technologies we're going to use here so we are going to use IntelliJ for Java we are going to use the database which is mongodb now why I'm choosing mongodb here why not our other database see the thing is there's a huge debate between SQL and nosql database databases which are good I have made a video and as well before this so you can find the link in description which talks about what is nosql so basically just to give an idea there are different types of databases available you can categorize them as SQL and non-sql in SQL we create tables right so we have a database in database we have tables so in in nosql basically we don't maintain this structure now why it is important is because when SQL got famous the at that point it was around 1970s at that point the memory was very costly so we have to make sure that we use minimum storage and we can install maximum data and that's why the SQL type of table makes sense now if you talk about the current world we have so much of data which is unstructured you can't actually create the columns based on that so what if your table is created and now you want to add a new column trust me it's a big headache in SQL that's one so basically we don't want to use SQL here the second one is you want to scale your application you want you want to have replicas of your of your database it is very difficult to do it in SQL of course you can have replicas but then it's very difficult to sync it so nosql database excel in that and we can Implement that with the help of bongodb so mongodb is a nosql database where you don't have tables what you have is documents so if you want to relate it's very easy database database is there on both the side in SQL we use tables right which is which has data here we have collections so we can have tables related to collections in SQL you store your data in the row format right so if you want to represent a particular entity let's say I want to store my information my name my age my phone number my email ID that becomes one row now that in no SQL becomes a document now the way we can have multiple rows in SQL we can have multiple documents which is a part of a collection that makes sense right so basically whatever data you're storing in fact the data which you have here this is a profile this is a description this is the experience and this is a technology you know so this becomes one document and if you have multiple data that multiple documents okay and we don't have to install any software for mongodb because we are going to use the cloud service and trust me this skill sets which we are going to do in today's session is very important okay so we I already have a IntelliJ on my machine which is entity Community version we are going to use that but then we want to create a spring project right and since we have a community version I'm not paying for it so we have to make sure that we have that second we want to create a service we want to create a mongodb service right so basically what we need to do is first we need to get the account on mongodb Atlas okay it's very simple you can just click on it and the important thing is it will not ask you for credit card information hopefully let's see if that is asking for you uh so I will sign up with my Google account and this should be a quick process so click on submit you can choose your email ID and you can choose you can click on submit I normally prefer to have Google login everywhere so that I don't have to remember the passwords so it says welcome you use your account to deploy a cloud database okay that's what you're going to do and you're still building it okay so basically it is asking you some questions you can just enter okay we are here to learn mongodb whatever application we are building we are building content management and then preferred language so basically we are going to do that with Java now that's the beauty about mongodb okay which is you can use multiple languages here now since we are going to use Java so I can click on Java here and click on finish now if you're getting confused how exactly the document looks like so if you have ever worked with JavaScript so JavaScript object you know how you create that's how the document is getting stored so basically that's a Json format for us but in the storage it is getting stored as Beason which is binary sun right which is Javascript or we can say one a Json to make it easy okay you're still loading the page maybe the Internet is slow on my side and that's why it is we got our story the only thing is it will ask you what type of service you want okay so if you can go for serverless you can go for dedicated but you have to pay for it now since we are into learning stage we can select the free one so you can you can click on share then you can click on create it will create a cluster for you now of course this is not a point where we talk about cluster imagine you're getting these services and the beauty is you can choose any of this cloud service so mongodb behind the scene will allow you to choose AWS or Google cloud or Azure so we are going to use AWS here okay so region is Mumbai by defaulty selecting the good things uh don't need to change anything here the only thing I want to change here is the cluster name I will name this cluster as thalisco and click on create cluster the next thing is it will ask you for the username and password to protect your database right so if you want to connect you have to enter the username password so you can see we have the root by default I've entered this before as well so it is taking the default values so you can enter whatever data you want to have I'm just typing root and root and I will click on create user so my user is created quite simple right the next thing I want to do is I will be using this from the local environment so I'm connecting my application which is running on my machine with the mongodb atlas so we have to enter the IP address I want to protect only I want to protect this by allowing that only my machine can use that database so I can click on add my current IP address click on that and click on finish and close so by doing this you got your database deployment so as you can see our database is created now what's the next step in fact we got our cluster naughty database if you can see we don't have a database yet so it says database deployment but then we need to create a database so you can see we have an option of database here when I click on database we already have one now what I will do is I will click on browse collection so basically we don't have a database we'll create that in this so this is the dashboard and we can see we have an option of monitoring but will not do all those things let's click on browse collection and as I mentioned the tables in SQL you can map it with the you can drop it with the collection here so let's click on the browse collection and it's trying to retrieve the database and you can see we don't have it yet so databases node of database is zero so we have a cluster ID which is telescope and we need to create a database now so click on add my own data so basically you can also load some sample data set which they provide you so if you don't want to have your own database or stuff I mean if you don't want to have your own data so you can click on load sample but since we have our own data we can click on add my own data here and it will ask you for database name so I will say this is for job listing and then the collection is job post in fact you know what I will do I will also keep my database name as telescope just just to make it easy and the collection name is job post so click on create okay so as you can see we got our database name as telescope and we got our collection name as job post and as you can see we have enough multiple options here we'll see this aggregation search index later so it will have a separate video on it and I also try to explain some of the more features but as of now just to keep it simple let's say this is our data here and as you can see we don't have any data it's empty so so we can click on insert document because I want to see some of the listings some of the jobs so I will click on insert document and this is how you can insert and the beauty is this data looks like a Json format maybe a key value pad just to simplify that now I don't want to enter the data by myself I already have some data set ready with me so as you can see this is the data I already have here so I will just copy paste this part into this so as you can see I have inserted data now how this data looks like so you can see we have an ID here we've got description the same thing which you were able to see on the page we got experience profile and the Technologies which you know and you can say this is an array basically in Java now how can you relate this with Java pojo so in the pojo we create a class right and we have different fields example if you talk about a person a person will have a name age now that thing comes as a key value pair here so you can say this is age this is name and stuff so I will click on insert it will insert some 11 10 11 records and you can see how many records we have so in total we have 10 records that's great so even this this enough in fact sometime in real application you'll be having a lot of data to play around but let's say we have 10 and I want to fetch this data from my Java application okay so remember this this is the thing we are building so if I remove the entire stuff this is what I want to fetch so what I will do now is so this thing is working because I already have this project ready in my IntelliJ so if you can see I was just doing some testing here so the project is ready but we are not going to use this project so I will stop this the moment I stop this project from this springboard so you can imagine we have two different applications running the front end and back end so what I will do now is if I go back to my browser if I refresh you can see data is not coming you know why because the server is not running of course you can do you can print some message here the server is done or something of course that comes at the later part but as of now I'm not printing any other you can check in the console log it will show you the other blood server is not running or something okay so this is what I want to make it work and as I mentioned before you can also use a Swagger API so let me show you how what Swagger API looks like of course we are going to build this the entire stuff one by one so let's say if I run this project and if if I go back to my browser and here I will run 8080 port and you can see the Swagger API is running with that so if you don't want to work on a UI part you can also use Swagger and you can see we have a post controller here and these are the options you have so even if you don't want to use frontend you can use Swagger you can get all the post so you can see if I click on try it now execute it will show me all the documents now this is coming because the server is running okay now if I stop the server even this will not work so if I click on execute now so you can see we got an error in fact this Swagger itself will not work so you can see that this is not working so if I open the Swagger home page it's not running so we have to make it work okay now for this what we're going to do we have to build the project from scratch so basically we have to go to one of the page which is star.spring.io now basically you you can use IntelliJ Enterprise version you can use Eclipse you can use SDS your choice but I'm going to use IntelliJ Community version where you don't have an option of creating a spring project by default so I'm going to use start.spring.io which is spring initializer now in this we are creating a maven project so basically imagine you're creating a project and you need certain modules you need certain project structure so you can click on Maven project here and we are going to use Java language the next thing is you have to specify the version which is 2.7.4 the only thing is if you want to use Swagger this version does not work properly so I will change the version once the project is created but if you don't want to use Swagger this perfectly works the next thing you have to mention is the group so I will say this is com.isco and the artifact is job listing okay that's the project and we can keep it as it is this is the package name that works for me and then we got the Java file so we have to create a Java file here so once you deploy the application when you export when you create a package the packaging will be happening as a jar not bar and you can choose a Java version 11 works so we can go for 11. now that also depends upon what setup you have in your machine so you need to have a code Java setup basically a dedicate setup uh 11 17 works you can use that 19 just launched so you can use that as well but I'm a I'm a person who prefers stability so I will go for 11. the next thing is you have to add dependencies now what are the differences when dependencies we need here so basically we are building a web project so I will use a web spring web okay uh the next thing I will need here is mongodb so I will search for mongodb so basically we want to go for spring data mongodb and the beauty is you know all these things which will happen happen with less amount of lines and trust me it's beautiful so if I click on this you don't have to write a lot of lines and Sometimes It's Tricky when you have a lot of lines so I will click on generate and you can you can see we've got our project here so what I will do is I will just unzip this project so you can see this is the project which is unzipped okay so I'm making sure that that project belongs to idea project so in my uh user account I have this folder which is called idea projects I'm equipping that project there so that I can open that internet from IntelliJ so I will open IntelliJ of course when you open this you will not say the project so this is what you will see and this is my demo project which I've already done and now I will click on open project from here so basically when you open IntelliJ IDEA of course this is the community version free one so I will click on open and navigate to the idea projects and in that I have a job listing click on open okay we have to trust we don't have a choice and we got the empty project as you can see we don't have a code here but I just want to verify if my pom file has it so Palm file you can see the version is this this will may not work with you so I'm going back to 2.5.7 there's not much change between these two versions and it perfectly works so this version normally works with swagger and so you also do it when you are trying this also try with the older version and once it is working then try to change the version to see that if that is working okay now these are the dependencies which I have right so if I it is you can see it is downloading dependencies whatever Java files you need in this project will be downloaded but till that point we also needed two more dependencies which is for Swagger now how will you get this dependency it's very simple uh you can go to one of the website called mvn repository and you have to get this too the Swagger UI and Swagger 2 okay so you can click on that search and you can click on the first one the version which normally works is you can go for 2.9.2 you can see we have a lot of views here so I will use this particular version copy this go back to your code and paste the same thing you can do for the second one with the Swagger two so you can see I'm searching for Swagger 2 here the first one and the same version make sure that you have the same version so that you will not get any conflicts and paste so you can see we got these two libraries and if I open my external libraries you will find all this uh files here so you can see we've got mongodb we got spring framework files and there should be for Swagger as well it will be there don't worry you it will be there so let's say if I minimize this now so we got swaggered in case it's always good to refresh your memo and dependencies you can also click on this Maven and click refresh it will make sure that you have all the dependencies required anyway otherwise it will give you either here if it is not working you can see we have all the jar files and now it's time to write our code the first thing you will do is if you go to your main see ultimately we have to connect our application with mongodb right so we have to specify where you do you have your mongodb do you have your mongodb in your system or you're trying to connect the cloud that's first second what is your database name what is username password of course right for connection you have to pass the credentials as well so what I will do is I will do all the configuration if you can see we have a resource folder in which you have application.properties this is where you do the configuration now it's a configuration I need here so basically I need spring dot data dot mongodb dot URI so this is the first property of your assign spring dot data.mongodb dot URL and we have to assign a URL now from where you will get the URL or URI in that case you will go back to our mongodb the cloud and you can see we have we should be having an option of if you go to overview you can see this option of connect okay so if you click on this connect here it will ask you for what type of from where you where you want to use this URI so I want to say I want to connect to an application so click on this now it will ask you which language you are using so we are doing it with Java and the version is this and this my friend is your URI so I will copy this and paste done okay the things we need to change you can see it's a long string the things you need to change here is you can see this this is your cluster name and this is the URI but password is not mentioned here so you can enter the password manually so the password for my machine is root so username wrote password is wrote and that should work the next thing I might do is this is where I want to specify the database name as well so basically this is the property so string dot data dot I mean spring.data.mongodb.database and this is where you have to mention your database name and I guess database name was the list code itself so we'll skip it the Disco I can just verify once again I can go back to the collections part here and you can see we have a database which is telescope so use the same name so database name is name is you can have a different so make sure that you enter your database name here okay that's it this is the property you have to mention and now I can simply close this I don't even need the form file close this okay now what next now we have to write a code to make it work so what I can do is I can go back to my Java and you can see we already have an application here now the thing is I want to enable this Swagger API and as of now we don't have a swaggered API enabled if you don't want to use Swagger you can skip the entire step and since we are not here to learn about Swagger and stuff so just to give an idea it helps you to request to your web service okay now if you don't want to use Swagger you can skip this step so if you can see I have just copy pasted and this is the only thing we are copy pasting okay because we are not here to learn about Swagger so the only thing you have to do is for the application you have to enable This Record too and we have to import the package for this uh we have to we have to make a bean because this is how this Swagger will load it as I mentioned before this is an optional step for the project so I'm just I'm not explaining this stuff because I just wanted to show you how do you build an application uh let me import the packages okay and the good thing is I will make sure that this budget is available in your uh in the link in the description as a GitHub link okay so this is done we have done with our main okay now this is only for Swagger and we are not going to use this file anymore so we have just enabled this Swagger okay but then now I want to send a request to the server right now how do how do we do that so in Spring framework basically we use something called Spring MVC which is model view controller and here we have to first create a controller and you can see we don't have a controller here so what I will do is I will create a new class and I will this is a class basically the name would be let's say post controller because now we are going to work with the post right job post so instead of saying job post every time I will say post controller and that's our controller here now how do you make this it's very simple you you make you make this controller with the help of flash controller okay and in this you will write your methods so for every request you want to send let's say I want to fetch all the post so I can use the URL which is localhost colon 8080 that's these that's the port number where the server will be running and I can say slash all post it will give me all the post what if I want to submit a new request so I can say slash post with the post method so the first one was get method the second will be post method and what if I want to search based on the term and for that we can use again a get to fetch but in this particular video we are going to focus only on how do you get all the records okay that's it or maybe I can also do it for the submit part but the first thing I want to do is I want to enable this Swagger right so in that case what I can do is I can create a method and this is only for swaggers for I can say redirect so every time someone send a request for the home page it should redirect to the Swagger page and to do that we have to import HTTP servlet response response okay so basically what I want to do is every time someone requests for the home page okay we have to do the mapping for that as well which is request mapping so when someone requests for the home page we have to mention that hey call this Swagger API okay and to do that what I will do is I will say response dot redirect and in bracket I can mention Swagger dot Swagger UI dot HTML and it is giving me some okay it's asking me to add the exception so I will say those are exception and that's it the Swagger UI will be ready let me just prove you that now to prove that I will run this application first I will right click the main uh application and save one okay it will take some time I hope it will work without any error okay you can see it is working and how do I verify that so I can just go back to the browser and okay Swagger your API is not working refresh enter and you can see we got our Swagger API it's simple and this is our controller name if I click on this controller you get all these options by default but I don't want this options so in that case I can again what I can do is I can just write API ignore API ignore okay that's it so when I say API ignored I need the server go back here and now I'm going to refresh so you can see it has removed all the predefined requests we want to Define our request by ourselves so I can say no operation defined in this specs okay that's good so what I can do is now I can Define the request now what request I want to send so basically here I want to have a option of fetching all the post now for that I can create a mapping so basically I want to work what what mapping we want to do we want to map it for all the posts so I can say public which will return the list of posts now what is this post hold on so for a document I also want a pojo right which will map the document and pojo okay we don't have a pojo here and the first and one more thing the post control should be a part of a controller right so let me just move that so it's a new package and it will make this as a controller I know let me just move this I want to create one more class here in fact one more package first package and this is where I will keep my models and in this model I want to create a pojo now what pojo a mapping class which will map my Java class with the document so I want to name this as post itself the job posting okay not the post method of HTTP the job posting and here I want to have some variables now what are the variables I need so if you compare with the database if I go back here so you can see we have a description in here let me just increase the font size a bit or it's not visible so you can see we have a description we have experience we have profile and we have technology which is an array the same thing you will be doing here okay so what are the things we need in the post so first of all we need a profile right so if you remember the database we had profile description Technologies and experience so let's put that so we got first thing we got we're going to get is the profile then we are going to get the description then we'll need the experience and the technology so we can say text that makes sense okay but then this text will be an added and that's done of course you can keep this bracket here as well that works and for this I need Getters and Setters so right click I will say generate uh I want a data center for all the fields and click on OK and with this I also need a Constructor generate a Constructor with in fact I I want a blank Constructor without any field and we also need a two string in case if I want to print that's it so I will say right click generate two string okay so we got our post right it's so simple okay so going back to the controller we got our post now so we can import the package that's imported and we have to also import the list that's done so if I want to fetch what method should I have so I can say get all post even that works and it name doesn't matter right so we can say get all posts and now I want to do a mapping for it so when do you call this particular method so you see of course the home page is done now homepage Returns the Swagger page but let's say in this Swagger if I go back and I want to have let's say uh are you one of its request for all the posts it should fetch the post so in that case I can just go back here and for get request I can say get mapping and the URL which I want to have is let's say all post so if we are requesting for all the posts or maybe I can simply say posts that works right so we can say posts and it should return the post but then how do I return the list here verify it will return empty that works now if I want to fetch this data what I will do now is I want to return the list how will I get the data so of course I want to fetch this data from database right now if you know kojava jdbc and database we have to write a lot of steps right but not in spring so we can use spring data remember we have added one of the library for spring data this one spring starter data so basically we can use that to fetch data and for that what I can do is I can create a new uh interface basically not the class interface and we'll name this as let's say post wrapper or we can say repository okay now this is this is how you will fetch data okay you don't have to write any methods any implementation I know that sounds new for some people they're like hey without writing any queries without writing anything how can I fetch data let me show you the magic now so what I can simply do is I can implement this interface or not implements I can extend this interface with the repository and in this you have to mention two things the first thing is uh what type of data you want to you want to fetch which is of course which is of post type so basically this is the mapping uh so whatever data whatever document your fetch will be a type post and the next thing is the primary key basically but then we don't have a key so I can keep it string I'm assuming that it will be string okay so let's get it that way uh and then that's it we don't have to write any methods in this you don't have to create any class which implements this the repository will take care of all the code operations fetching creating updating and deleting okay that sounds fun right let me show you so what I can simply do is once I got this Repository remember I don't I'm not creating any class or stuff I'm just going top here and I'm saying create the object of post repository not the object but not not the object of the interface but behind the scene the spring framework will create a class for it it will create an object for it you don't have to do that and I will simply said this is a Zappo and I will just map this as Auto wire So when you say AutoVoice it simply means spring will create an object for you and it will map it that's it that that auto wiring part and you don't have to do anything else just come back here and say repo dot find organ so that we have so many methods we have not written those methods it's in build in repository that's it I know you will not trust me at this point the only way I can prove my point here is by restarting the application and I know you might be saying there is a difference between the time here it's just that my camera was not working properly so I have to take a pause and do it again and if I refresh oh okay so that we got all post and if I click on this hopefully this will work it's already been a lengthy video I will click on try it out execute oh okay we got data but it's not printing data here oh something went wrong here so we're requesting for posts and it is requesting for the Post find all okay now what is missing remember when we go for the Post repository we have mentioned that there's a post right there should be mapping but post is not aware of that so what we have to do is we have to say document here and we have to mention which collections this will map to so this will map to okay what's my collection name if I go back to my thing it is job post so we'll just come back here and say job post now this should work so if I start the server there's no error and if I go back to my Swagger API hopefully this time it will work execute oh okay so that we got the data this is what we wanted right oh it's working and if you look at the code it's so simple we just got a controller here where we are doing the mapping we got the post repository and nothing much here we're not declaring any methods or stuff and if I look at the post this is just a pojo so fetching is working that's awesome how about posting the data what if I want to submit data Maybe I want so apart from this all post I also want to have post which was submit data a post method let's try this should be simple so I can create I can simply create another method here for posting data what if I want to get my own records so I can create a method which will return the post itself so whatever post you are submitting it will return that and I will say add post of course method name can be anything and okay the mapping what type of mapping I'm going to do any guess we are submitting data so for submitting we have to use post mapping and here we have to specify the U model I can I say URL post see when I say posts for get it is it will fetch okay so in the method we are specifying it's get method so it will fetch in post we are submitting data okay this post and post might be confusing but this this post is basically the job post this post is HTTP method but then when you submit data we have to also accept it right here so I can use a request body here to accept now say if you don't understand all this concept say flow is something very easy right easy right but what if you want to do do it by yourself don't worry I have a spring boot tutorial you will find the link in description which explains each and everything properly this is a project video right so I'm just focusing around the project part okay so request body and here I can mention the object where it will receive the data so I wanted to receive data in a post format so whatever data you will submit from this from the client side will be accepted here in the post object I know that's something which spring is amazing at okay once you've got the data I can simply say repo dot uh okay how do I which method I have to use for saving I should I think there's a save method yeah there's a save method which will accept the post object that's it that's it no need to mention any query no need to mention any code for it we are done with this but I guess save return something okay what I will do is save Returns the object of course so we can simply say save it will return the post object and returning it that's it and here I think it should work if I go back or we have to restart the server so you can see we are fetching data we are also submitting data and if I go back refresh okay both okay so that we got post here that's that's awesome and you can see it will give you some demo data as well so that it is already mapped right so I want to submit data I can say description okay description or first of all I will set the profile profile I'm looking for is blockchain developer and here description can be ethereum developer with dapps experience in Mumbai or maybe I can say this time I can say Pune okay experience I need only two years Blossom developer technology what you should know let's say you should know Java I don't know why you should know Java but let's say Java then we can say solidity and you need to know XML I don't know why but let's say XML and let's click on execute it should work oh it worked you can see that we got the data but then we are getting the data on the client side right let's verify from database so if I go to database now and let's see if that is there Let me refresh the database hopefully it should be there it should be there it should be there if I scroll down down down can you see that we got the blockchain developer ethereum developer whatever we have written there and the array of your skills awesome it was so simple right so basically we were able to request data we were able to save data but of course at this point we have only worked with the Swagger part we have not connected with the UI uh we'll do that and also there is no searching option okay we have not created something for searching we'll do that in the next video so in the next video we'll also try to understand how will you use mongodb what is the feature it provides and then we'll explore one more application which is called mongodb Compass okay which is a UI basically I'm just everything which I'm going to do I'm just going to the browser right and I'm accessing the cloud service what if I want to access everything on a desktop application sometimes it's very easy to access a desktop application then going to the website so we'll try to explore that as well okay and yeah so that's it from this video where we have created this project of don't worry we'll complete this project on the in the third video uh second video we'll talk about mongodb compass and all those stuff so that you will get more idea how to use mongodb how powerful it is and in the third video we'll complete the search part as well so that's it from this video I hope you enjoyed uh let me know in the comment section and don't worry if you don't understand some of the things you can find the video in the description which talks about spring boot you can watch that video okay bye everyone thank you so much
Info
Channel: Telusko
Views: 21,095
Rating: undefined out of 5
Keywords: telusko, navin, reddy, tutorial, java, python, blockchain, django
Id: 6QnY7Ri_ORw
Channel Id: undefined
Length: 40min 59sec (2459 seconds)
Published: Sun Sep 25 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.