本文整理了Java中org.springframework.data.mongodb.core.query.Update.push()
方法的一些代码示例,展示了Update.push()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Update.push()
方法的具体详情如下:
包路径:org.springframework.data.mongodb.core.query.Update
类名称:Update
方法名:push
[英]Update using $push modifier.
Allows creation of $push command for single or multiple (using $each) values as well as using $position.
[中]使用$push修改器更新。
允许为单个或多个(使用$each)值以及使用$position创建$push命令。
代码示例来源:origin: spring-projects/spring-data-mongodb
/**
* Propagates {@link #value(Object)} to {@code $push}
*
* @param value
* @return never {@literal null}.
*/
public Update value(Object value) {
if (this.modifiers.isEmpty()) {
return Update.this.push(key, value);
}
this.modifiers.addModifier(new Each(Collections.singletonList(value)));
return Update.this.push(key, this.modifiers);
}
代码示例来源:origin: spring-projects/spring-data-mongodb
/**
* Propagates {@code $each} to {@code $push}
*
* @param values
* @return never {@literal null}.
*/
public Update each(Object... values) {
this.modifiers.addModifier(new Each(values));
return Update.this.push(key, this.modifiers);
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
/**
* Propagates {@link #value(Object)} to {@code $push}
*
* @param value
* @return never {@literal null}.
*/
public Update value(Object value) {
if (this.modifiers.isEmpty()) {
return Update.this.push(key, value);
}
this.modifiers.addModifier(new Each(Collections.singletonList(value)));
return Update.this.push(key, this.modifiers);
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
/**
* Propagates {@code $each} to {@code $push}
*
* @param values
* @return never {@literal null}.
*/
public Update each(Object... values) {
this.modifiers.addModifier(new Each(values));
return Update.this.push(key, this.modifiers);
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Override
public void addDemoDataPostfix(String project, String postfix) {
mongoTemplate.updateFirst(projectById(project), new Update().push("metadata.demoDataPostfix", postfix), Project.class);
}
代码示例来源:origin: bsinno/iot-things-examples
/**
* Write history to the the MongoDB
*/
private void storeHistory(History h) {
LOGGER.trace("Store history (max {}): {}", h);
// do combined update query: add newest value+timestamp to the array property and slice array if too long
String id = h.thingId + "/features/" + h.featureId + h.path;
Update update = new Update()
.push("values",
new BasicDBObject("$each", Arrays.asList(getJavaValue(h.value)))
.append("$slice", -HISTORY_SIZE))
.push("timestamps",
new BasicDBObject("$each", Arrays.asList(h.timestamp))
.append("$slice", -HISTORY_SIZE));
// update or create document for this specific property in this thing/feature
mongoTemplate.upsert(
Query.query(Criteria.where("_id").is(id)),
update, String.class, "history");
}
代码示例来源:origin: pl.edu.icm.polindex/polindex-tools
result.push(MongoUtil.F_TAGS, tag.getTag());
代码示例来源:origin: pl.edu.icm.polindex/polindex-tools
@Override
public int addTag(RecordQuery recordQuery, Tag tag) {
Update update = new Update().push(F_TAGS, tag.getTag());
logger.debug("executing mongo update: {} on records selected by: {}", update.getUpdateObject(), recordQuery.getQuery());
WriteResult res = mongoTemplate.updateMulti(recordQuery.getQuery(), update, collectionName);
logger.debug("added tag " + tag + " to " + res.getN() + " records");
return res.getN();
}
代码示例来源:origin: flyleft/xmarket-server
@Override
public void addToUserTrades(String which_col, String userId, String trade_id) {
template.updateFirst(new Query(where("_id").is(userId)),
new Update().push(which_col,trade_id), User.class);
}
代码示例来源:origin: flyleft/xmarket-server
@Override
public void updateUserTeams(String userId, String teamId) {
template.updateFirst(new Query(where("_id").is(userId)),
new Update().push("teams",teamId), User.class);
}
代码示例来源:origin: flyleft/xmarket-server
@Override
public void addToTeamTrades(String team, String tradeId) {
template.updateFirst(new Query(where("name").is(team)),
new Update().push("trades",tradeId), Team.class);
}
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Override
public void addRetry(String id, TestItem retry) {
mongoTemplate.updateFirst(query(where(ID_REFERENCE).is(id)), new Update().push("retries", retry), TestItem.class);
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Override
public void addContentField(String widgetId, String field) {
mongoTemplate.updateFirst(query(where("_id").is(widgetId)), new Update().push(CONTENT_FIELDS, field), Widget.class);
}
内容来源于网络,如有侵权,请联系作者删除!