@Override
        public Integer call() {
          collection().replaceOne(convertToBson(criteria), document, new ReplaceOptions().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;
        }
Codec used for current collection type.
@return registry
mongo/src/org/immutables/mongo/repository/Repositories.java