This Project helps you to understand Spring-powered, production-grade applications using MongoDB. It takes an opinionated view of the Spring platform so that new and existing users can quickly get to the bits they need.
Primary goals are:
- Provide a radically faster and widely accessible getting started experience using Mongo Db and Spring Boot. s
The reference documentation includes detailed installation instructions of MongoDb server on Mac OS.
To Visualize MongoDb I used Studio 3t
Here is a quick teaser of a complete Spring Boot application in Java:
@SpringBootApplication
@EnableMongoRepositories
public class NosqlApplication {
public static void main(String[] args) {
SpringApplication.run(NosqlApplication.class, args);
}
}db.getCollection("student").find({
$or: [{
"name": "steve"
}, {
"mail": "steve@gmail.com"
}
],
"name": {
$in: ["john"]
}
})This query will find documents in student collection having given name or mail and name in given parameter
- The
StudentControllerclass, providing static convenience methods that can be used to write a stand-alone Rest API Spring Application.
@RestController
@RequestMapping("/api/student")
public class StudentController {
@Autowired
StudentService studentService;
@PostMapping
public Student createStudent(@RequestBody Student student) {
//create document
return studentService.createStudent(student);
}
}- Embedded web applications with a choice of container (Tomcat, Jetty, or Undertow).
- URLs
-
this document for more information on Pagination, CRUD Basic Logic.
-
Query on
PaginationandSortingin MongoDBdb = db.getSiblingDB("spring"); db.getCollection("student").find({ }).sort({ "name": 1.0 }).skip(0).limit(10);
-
- After successful Hit the URL
