Showing posts with label MongoDB. Show all posts
Showing posts with label MongoDB. Show all posts

Saturday, May 9, 2020

Spring Boot Data MongoDB: Projections and Aggregations Examples

1. Introduction


In this tutorial, You'll learn how to use Spring Data MongoDB Projections and Aggregation operations with examples.

Actually, Spring Boot Data MongoDB provides a plain and simple high-level abstraction layer to work with Mongo native queries indirectly.

If you are new to Spring Boot MongoDB, then refer the previous article on "MongoDB CRUD Operations in Spring Boot"

Spring Boot Data MongoDB: Projections and Aggregations Examples


First, We'll see what is Projection and a few examples on this. 
Next, What is an aggregation along with some examples such as to do grouping, sort, and limit operations.

We are going to use the Employee document in this article, showing the data already present in the table.

Thursday, May 7, 2020

Spring Boot MongoDB CRUD Operations Example

1. Introduction


In this tutorial, You'll learn how to do CRUD operations in MongoDB database as part of the Spring Boot Application.

MongoDB is a NoSQL database that uses JSON as a schema.

CRUD operations have been considered in computer programming as create, read, update, and delete (CRUD) are the four basic functions of persistent storage

Another example of How to generate auto-increment id in MongoDB Spring Boot App

Let us see step by step how to do it in a simple way.

Spring Boot MongoDB CRUD Operations Example


Tuesday, March 31, 2020

Auto-Generated Field for MongoDB using Spring Boot - Step By Step

Outline:

In this tutorial, we are going to learn how to implement a sequential and auto-generated field for MongoDB in Spring Boot. If you are new to MongoDB and Spring then visit  Spring Data MongoDB Tutorial.

Understanding step by step today about "Auto-Generated Field for MongoDB using Spring Boot"

Spring Boot Tutorials

[update] Updated new errors in this article.
This is a very common scenario that arises when using MongoDB and Spring framework integration work.

When we are using MongoDB databases as part of the Spring Boot application directly we can not use @GeneratedValue annotation in our database model classes.

@GeneratedValue: Marking a field with the @GeneratedValue annotation specifies that value will be automatically generated for that field and mainly this is used on primary key fields. This annotation is available only for JPA API.



Auto-Generated Field for MongoDB using Spring Boot


The easy solution to this problem is very simple. We will create a collection or table that will store the generated sequence for other collections. During the creation of a new record, we’ll use it to fetch the next value.