About MongoDB
MongoDB is a distributed file-based database that is a product between relational and non-relational databases, with the main goal of building a bridge between key/value storage (which provides high performance and high scalability) and traditional RDBMS systems (with rich functionality). It combines the advantages of both.
MongoDB supports a very loose data structure, a JSON-like Bson format, so it can store more complex data types, and because his storage format makes it very fluid to store the data in the NODEJS program application.
Since it is called a NoSQL database, the query language of MONGO is very powerful, its syntax is somewhat similar to object-oriented query language, almost can realize the most functions like relational database single table query, but also support the indexing of data.
However, MongoDB is not omnipotent, compared to MySQL and other relational databases, they have their own unique advantages for different data types and transaction requirements. In the choice of data storage, adhere to the principle of diversification, choose a better and more economical way, rather than top-down unification.
More commonly, we can directly use MongoDB to store key value pairs of data types, such as: Verification Code, session, etc. due to MongoDB's scale-out capability, it can also be used to store data that is very large in the future, such as: logs, comments, etc. Because MongoDB stores the weak type of data, it can also be used to store some changeable JSON data, such as: the interaction with the external system is often changed JSON message. For some operations that have complex, high-transactional requirements for data, such as account transactions, it is not appropriate to use MONGODB for storage.
MongoDB website
Visit MongoDB
In spring boot, a self-configuring feature is also provided for such a popular mongodb.
Introducing Dependencies
Spring boot can be relied upon to pom.xml
spring-boot-starter-data-mongodb
introduce access support to MongoDB by adding in. Its implementation depends spring-data-mongodb
. Yes, you have not read the wrong, but spring-data
also the sub-project, previously introduced spring-data-jpa
, spring-data-redis
and for MongoDB's access to spring-data
provide a strong support, the following start to try it.
<dependency> <groupId>org.springframework.boot</groupId> <artifactId> Spring-boot-starter-data-mongodb</artifactid></dependency>
Source Source
Spring Boot Tutorial (35) using the MongoDB database (1)