MongoDB Aggregation Operations

You are not going to always return records from MongoDB but sometimes you need to perform some computations such as sum, count, average, etc. Here you need the aggregation operations which are used to process data that return the computed results. Therefore aggregation actually groups data from multiple documents and performs a variety of operations on the grouped data to return the single result. Aggregate operations retrieve a single value after performing a calculation on a set of values. Often aggregate functions are accompanied by group clause in the find()…

Continue

MongoDB find() method with Projection

You may not want to fetch a whole bunch of data from the document which is stored in a collection in your MongoDB database. You can restrict the number of records or data using different conditions with the help of WHERE, AND, OR and IN operators, but what if you want to restrict the data you want in your particular row or record or document. So here comes the projection that helps you to selectively choose data from a record or row or document. In MongoDB, projection means selecting only…

Continue

How to query documents – WHERE, AND, OR, IN conditions in MongoDB

MongoDB is one of the most popular NoSQL database where data are stored in the form of documents. You can also create tables in traditional way to put your structured data but the main purpose is to store unstructured data in the form of object which may vary based on a particular requirement. Now when you select data from collection, you may not need all data to be fetched from the database collection and you want to restrict those data based on certain criteria or conditions while fetching from database.…

Continue

How to make output of MongoDB’s find() readable in shell

MongoDB is one of the most popular NoSQL database where your data are stored in a collection. To quickly access your data from MongoDB you can execute commands on MongoDB shell and your results appear based on the given criteria. One of the commands is find() function and using this command you can easily retrieve data from MongoDB collection. When you execute this find() command to retrieve data from a collection, it displays data in one line which makes it ugly and become difficult to read specially when there multiple…

Continue

Codeigniter MongoDB CRUD Example

Introduction Here we will see Codeigniter MongoDB CRUD example, where CRUD means Create, Read, Update and Delete. So basically we will perform creating new user, reading users/user, update existing user and deleting existing user operations into MongoDB. MongoDB is one of the widely used NoSQL(Not only SQL) database in market today. MongoDB is a document database with the scalability and flexibility that you want with the querying and indexing that you need. Often we come across a situation where we end up using MongoDB with PHP based framework Codeigniter.

Continue

WebSocket on Spring MongoDB Reactive Programming

Introduction Here we will see an example on WebSocket on Spring MongoDB Reactive Programming. In past we have see few examples on WebSocket but this example will use Spring WebFlux, i.e., WebSocket on Spring Reactive API. WebFlux includes reactive WebSocket client and server support. Both client and server are supported on the Java WebSocket API (JSR-356), Jetty, Undertow, Reactor Netty, and RxNetty. On the server side, declare a WebSocketHandlerAdapter and then simply add mappings to WebSocketHandler-based endpoints.

Continue

Spring MongoDB Functional Reactive Microservices Example

Introduction In this three pages post we will see how to create Spring MongoDB Functional Reactive Microservices Example. We are going to use here Spring 5’s Webflux API. We will also see here how to use Flux and Mono with ServerResponse, ServerRequest in Handler function. We will know how to use RequestPredicates in Router function in subsequent sections. We will use Spring Cloud, Eureka server and Ribbon for implementing our example. If you want to know about reactive or functional reactive programming then you need to go through Spring Boot…

Continue

Spring Boot MongoDB Functional Reactive CRUD Example

Introduction We will see here Spring Boot MongoDB Functional Reactive CRUD Example. We have seen our previous example on Spring Boot Functional Reactive Programming but we did not use any persistent storage like MongoDB but here we are going to use MongoDB for performing CRUD operations. We are going to use Spring 5’s Webflux API with reactive stream to implement our Spring Reactive program. This is a Spring Reactive programming example implemented in a functional way using Java’s lambda expression. If you want to know detail on Reactive Programming or…

Continue

Angular + Spring Boot MongoDB CRUD Example

Introduction In this post we will create Angular + Spring Boot MongoDB CRUD Example. In my previous tutorial on Spring Boot MongoDB CRUD Example, we did not have any UI or front-end, so we had to test out application using REST client but here we will use Angular on front-end side so that we can easily make this application as a full-stack and deliver to the end users for performing real time activities. Prerequisites Spring Boot MongoDB CRUD Example Angular 7 Now we will see how to implement Angular +…

Continue