org.springframework.data.mongodb.core.query.Update.fromDocument()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(1.4k)|赞(0)|评价(0)|浏览(395)

本文整理了Java中org.springframework.data.mongodb.core.query.Update.fromDocument()方法的一些代码示例,展示了Update.fromDocument()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Update.fromDocument()方法的具体详情如下:
包路径:org.springframework.data.mongodb.core.query.Update
类名称:Update
方法名:fromDocument

Update.fromDocument介绍

[英]Creates an Update instance from the given Document. Allows to explicitly exclude fields from making it into the created Update object. Note, that this will set attributes directly and not use $set. This means fields not given in the Document will be nulled when executing the update. To create an only-updating Update instance of a Document, call #set(String,Object) for each value in it.
[中]从给定文档创建更新实例。允许在创建的更新对象中明确排除字段。请注意,这将直接设置属性,而使用$set。这意味着在执行更新时,文档中未给出的字段将为空。要创建文档的唯一更新实例,请为其中的每个值调用#set(String,Object)。

代码示例

代码示例来源:origin: spring-projects/spring-data-mongodb

public UpdateDefinition updateWithoutId() {
  return new MappedUpdate(Update.fromDocument(document, ID_FIELD));
}

代码示例来源:origin: org.springframework.data/spring-data-mongodb

public UpdateDefinition updateWithoutId() {
  return new MappedUpdate(Update.fromDocument(document, ID_FIELD));
}

代码示例来源:origin: onsoul/HA-DB

public T update(String id, Document updoc, T t) {
  Update update = Update.fromDocument(updoc, "");
  Query query = Query.query(Criteria.where(Opations.ID_FIELD).is(id));
  T result = (T) mongoTemplate.findAndModify(query, update, t.getClass());
  return result;
}

相关文章