简体   繁体   English

Spring Data MongoDB更新自定义字段

[英]Spring data mongodb update custom field

I have an _id of mongodb object and want to update only a specific field in DB. 我有一个mongodb对象的_id ,只想更新数据库中的特定字段。 Is there a way not to get the entire object with findone(id) then set required field and save to mongodb again? 有没有办法不使用findone(id)获取整个对象,然后设置必填字段并再次保存到mongodb? I want something like sql update mechanism which didn't find in mongodb yet. 我想要类似mongodb中找不到的sql更新机制。 I use java Spring data. 我使用java Spring数据。

I am assuming that you are using spring-data-mongodb , 我假设您正在使用spring-data-mongodb

MongoTemplate has convenient methods for update / upsert . MongoTemplate有方便的方法更新 / 更新插入

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 用于枚举字段的mongoDb和spring数据自定义转换器 - mongoDb and spring data custom converter for enum field 更新字符串字段,将 mongodb 中的另一个字符串与 spring-data 连接起来 - Update string field concatenating another string in mongodb with spring-data Spring:使用现有字段更新 MongoDB - Spring: Update MongoDB with existing field 如何在Spring数据MongoDB中创建自定义字段名称 - how to make custom field name in spring data mongodb 更新 1 个或多个特定字段 MongoDB 使用 Spring 启动 WebFlux,Spring 数据 Z206E3718AF0921CC1D12F80ZReposit7 - Update 1 or multiple specific field MongoDB using Spring boot WebFlux,Spring Data MongoDB Reactive and ReactiveMongoRepository Spring Data MongoDB 和批量更新 - Spring Data MongoDB and Bulk Update 自定义MongoDB spring数据存储库 - Custom MongoDB spring data repository 自定义映射Spring MVC,Spring Data MongoDB - Custom mapping Spring MVC, Spring Data MongoDB Spring 数据 mongoDb controller 如何将文档更新为辅助文档中的字段 - Spring data mongoDb controller how can I update document as a field in side document Spring Data MongoDB - 使用自定义 Id 字段时,注释 @CreatedDate 不起作用 - Spring Data MongoDB - Annotation @CreatedDate does not work while using with custom Id field
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM