Repositories.java 文件源码

java
阅读 39 收藏 0 点赞 0 评论 0

项目:GitHub 作者:
protected final FluentFuture<Integer> doUpsert(
    final Constraints.ConstraintHost criteria,
    final T document) {
  checkNotNull(criteria, "criteria");
  checkNotNull(document, "document");
  return submit(new Callable<Integer>() {
    @Override
    public Integer call() {
      collection().replaceOne(convertToBson(criteria), document, new UpdateOptions().upsert(true));
      // upsert will always return 1:
      // if document doesn't exists, it will be inserted (modCount == 1)
      // if document exists, it will be updated (modCount == 1)

      return 1;
    }
  });
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号