Implementing of Spring Data MongoDB repositories

With the domain model implemented successfully, its MovieRepository can be implemented using Spring Data MongoDB. The specialty of this is that there is no need to implement anything. Just writing an interface that extends from the ReactiveMongoRepository interface would be sufficient to expose the methods to find one, find all, save, delete, and so on. The following code shows MovieRepository:

interface MovieRepository : ReactiveMongoRepository<Movie, Int>

The following code shows, UserRepository:

interface UserRepository : ReactiveMongoRepository<User, Int> {
fun findByUsername(username : String) : Flux<User>;
}

The preceding UserRepository has a custom method written to query the MongoDB user's collection and find users by username.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.72.74