Skip to content

suyashs52/spring-nosql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SpringBoot MongoDB

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

Installation and Getting Started

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);
	}

}

MongoDB Query

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

Usage

  • The StudentController class, 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);
   }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages