What are the basic operations of spring+mongo
This article mainly explains "what are the basic operations of spring+mongo". Friends who are interested may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn what are the basic operations of spring+mongo.
Mongo configuration:
Inject mongoTemplate when in use
@ Autowiredprivate MongoTemplate mongoTemplate;Order order = new Order (1LMagne111, "test"); / / add mongoTemplate.insert (order); Query query = new Query () .addCriteria (Criteria.where ("userId"). Is (111); / / query System.out.println (mongoTemplate.find (query,Order.class)); Update update = new Update (). Set ("userId", "222"); / / Update System.out.println (mongoTemplate.updateFirst (query,update,Order.class))
Other operations of mongoTemplate are similar, and you can also integrate jpa to use
At this point, I believe you have a deeper understanding of "what are the basic operations of spring+mongo?" you might as well come to the actual operation! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!