本文整理了Java中org.springframework.data.mongodb.core.MongoTemplate.upsert()
方法的一些代码示例,展示了MongoTemplate.upsert()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MongoTemplate.upsert()
方法的具体详情如下:
包路径:org.springframework.data.mongodb.core.MongoTemplate
类名称:MongoTemplate
方法名:upsert
暂无
代码示例来源: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: at.researchstudio.sat/won-bot
private void pull(String collectionName, String key, final Serializable... values) {
Update update = new Update();
Query query = new Query(Criteria.where("_id").is(key));
// pull values of the field "objectList" since this is the name of the member variable of MongoContextObjectList
template.upsert(query, update.pullAll("objectList", values), collectionName);
}
代码示例来源:origin: eventuate-tram/eventuate-tram-examples-customers-and-orders
@Override
public void addOrder(Long orderId, Money orderTotal) {
mongoTemplate.upsert(new Query(where("id").is(orderId)),
new Update().set("orderTotal", orderTotal), OrderView.class);
}
代码示例来源:origin: at.researchstudio.sat/won-bot
private void push(String collectionName, String key, final Serializable... value) {
Update update = new Update();
Query query = new Query(Criteria.where("_id").is(key));
// push values to the field "objectList" since this is the name of the member variable of MongoContextObjectList
// from there we can easily access it again for loading
template.upsert(query, update.pushAll("objectList", value), collectionName);
}
代码示例来源:origin: eventuate-tram/eventuate-tram-examples-customers-and-orders
@Override
public void updateOrderState(Long customerId, Long orderId, OrderState state) {
mongoTemplate.upsert(new Query(where("id").is(customerId)),
new Update().set("orders." + orderId + ".state", state), CustomerView.class);
}
}
代码示例来源:origin: eventuate-tram/eventuate-tram-examples-customers-and-orders
@Override
public void addCustomer(Long customerId, String customerName, Money creditLimit) {
mongoTemplate.upsert(new Query(where("id").is(customerId)),
new Update().set("name", customerName).set("creditLimit", creditLimit), CustomerView.class);
}
代码示例来源:origin: eventuate-tram/eventuate-tram-examples-customers-and-orders
@Override
public void addOrder(Long customerId, Long orderId, Money orderTotal) {
mongoTemplate.upsert(new Query(where("id").is(customerId)),
new Update().set("orders." + orderId, new OrderInfo(orderId, orderTotal)), CustomerView.class);
}
内容来源于网络,如有侵权,请联系作者删除!