Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What are the basic operations of spring+mongo

Shulou Source: shulou.com Published: 2022-06-02 10:09:03 11月13日 Update

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!

Tags: Basic operation content learning query practical deeper interest practicality practical simple operation method more friends website channel update configuration Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi NVidia Apple vpn MariaDB