Sigrid  Farrell

Sigrid Farrell

1622096221

Spring Boot & MongoDB: Searching and Pagination

Implement searching and pagination in a Spring Boot application using MongoTemplate

MongoTemplate  class provides us features for interacting with the database and offers operations to create, update, delete, and query MongoDB documents in a thread-safe way. The MongoTemplate  class implements the interface MongoOperations . You can find methods like findfindAndModifyfindAndReplacefindOneinsertremovesaveupdate  etc… MongoOperations  has fluent APIs for Query  and Criteria  which we will use in this example.

#mongodb #spring #spring-mongo-db #spring-data #spring-boot

What is GEEK

Buddha Community

Spring Boot & MongoDB: Searching and Pagination
Sigrid  Farrell

Sigrid Farrell

1622096221

Spring Boot & MongoDB: Searching and Pagination

Implement searching and pagination in a Spring Boot application using MongoTemplate

MongoTemplate  class provides us features for interacting with the database and offers operations to create, update, delete, and query MongoDB documents in a thread-safe way. The MongoTemplate  class implements the interface MongoOperations . You can find methods like findfindAndModifyfindAndReplacefindOneinsertremovesaveupdate  etc… MongoOperations  has fluent APIs for Query  and Criteria  which we will use in this example.

#mongodb #spring #spring-mongo-db #spring-data #spring-boot

Maryse  Reinger

Maryse Reinger

1625802780

Spring Data MongoDB Delete Operation |Spring Boot+Spring Data MongoDb+MongoTemplate Delete

Spring Data MongoDB - Delete document | Spring Data MongoDB Delete Operation | Spring Boot MongoDB Delete

Hello and namaste everyone,

Today, we are learning how to delete a document in spring data mongodb. We are using mongoTemplate to delete the document. Spring Data MongoDB provides different functions to delete the document. we will understand the difference between these functions and their usage.

#springDataMongoDb #springDataMongodbDelete #mongoTemplate #springBooot #javaMongodb #smartyetchFizz

Email at: smartytechfizz@gmail.om
Follow on Instagram: https://www.instagram.com/smartytechfizz/

#spring data mongodb #mongodb #spring boot #spring data mongodb #mongotemplate delete

Were  Joyce

Were Joyce

1620751200

How to Configure the Interceptor With Spring Boot Application

In the video in this article, we take a closer look at how to configure the interceptor with the Spring Boot application! Let’s take a look!

#spring boot #spring boot tutorial #interceptor #interceptors #spring boot interceptor #spring boot tutorial for beginners

Were  Joyce

Were Joyce

1620720872

Spring vs Spring BooDifference Between Spring and Spring Boot

As an extension of the Spring Framework, Spring Boot is widely used to make development on Spring faster, more efficient and convenient. In this article, we will look at some of the parameters were using Spring Boot can drastically reduce the time and effort required in application development.

What is Spring?

Spring Boot

Difference between Spring and Spring Boot

Advantages of Spring Boot over Spring

Conclusion

#full stack development #spring #spring and spring boot #spring boot

Dev Life

1609494732

Spring Boot Pagination & Filter example | Spring JPA, Pageable

In this tutorial, I will continue to make Server side Pagination and Filter with Spring Data JPA and Pageable.

Full Article: https://bezkoder.com/spring-boot-pagination-filter-jpa-pageable/

For MongoDB database:
Spring Boot MongoDB Pagination & Filter example with Spring Data

Spring Boot Pagination & Filter example overview

One of the most important things to make a website friendly is the response time, and pagination comes for this reason. For example, this bezkoder.com website has hundreds of tutorials, and we don't want to see all of them at once. Paging means displaying a small number of all, by a page.

Assume that we have tutorials table in database like this:

spring-boot-pagination-filter-example-spring-jpa-pageable-table

Here are some url samples for pagination (with/without filter):

  • /api/tutorials?page=1&size=5
  • /api/tutorials?size=5: using default value for page
  • /api/tutorials?title=data&page=1&size=3: pagination & filter by title containing 'data'
  • /api/tutorials/published?page=2: pagination & filter by 'published' status

This is structure of the Server side pagination result that we want to get from the APIs:

{
    "totalItems": 8,
    "tutorials": [...],
    "totalPages": 3,
    "currentPage": 1
}

Read Tutorials with default page index (0) and page size (3):

spring-boot-pagination-filter-example-spring-jpa-pageable-default

Indicate page index = 2 but not specify size (default: 3) for total 8 items:

  • page_0: 3 items
  • page_1: 3 items
  • page_2: 2 items

spring-boot-pagination-filter-example-spring-jpa-pageable-page

Indicate size = 5 but not specify page index (default: 0):

spring-boot-pagination-filter-example-spring-jpa-pageable-size

For page index = 1 and page size = 5 (in total 8 items):

spring-boot-pagination-filter-example-spring-jpa-pageable-page-size

Pagination and filter by title that contains a string:

spring-boot-pagination-filter-example-spring-jpa-pageable-title

Pagination and filter by published status:

spring-boot-pagination-filter-example-spring-jpa-pageable-status

For more details, implementation and source code, please visit:
https://bezkoder.com/spring-boot-pagination-filter-jpa-pageable/

Further Reading

To bring pagination and sorting together, please visit:
Spring Boot Pagination and Sorting example

Handle Exception for this Rest APIs is necessary:
Spring Boot @ControllerAdvice & @ExceptionHandler example

You can also know how to deploy this Spring Boot App on AWS (for free) with this tutorial.

React Pagination Client that works with this Server:
React Pagination with API using Material-UI

Alt Text

Angular Client working with this server:

Or Vue Client:

Happy learning! See you again.

#spring #spring-boot #pagination #spring-data #web-development #java