java - Springboots 允许保存重复文件


编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。

关闭 2 年前

Improve this question

我一直在使用 MongoDB 和 Spring Boot。我创建了一个小型网络应用程序,但似乎遇到了一个错误。在我将 Web 应用程序部署到 EC2 并设置好所有内容后,我尝试了不同的场景。一个是我和我的 friend 试图将同一个对象保存到数据库中。这应该是不可能的,因为在我的代码中我已经限制了它,所以它会出错。但不知何故,如果时机完美,我们都可以保存文档。我们使用我们的方法 contains 检查文档是否已经存在,但在这种情况下它似乎失败了。

    /**
     * @param id ID of the document we are looking for
     * @return true or false based on if the Doc with given ID exists
     */
    @Override
    public boolean contains(String id) {
        return eventModelRepo.findById(id).isPresent();
    }

如有任何关于如何解决此问题的建议,我们将不胜感激。

相关文章:

c# - 解析值行 1,位置 1 时遇到意外字符

reactjs - 我需要将浏览器路由器一分为二

python-3.x - XGboost 目标 : Is there a way to do Mul

postgresql - Postgres JSONB 检索非常慢

postgresql - 使用 Aurora postgres serverless 在 AWS R

reactjs - 确定派发返回值的类型

php - 文件上传按钮在翻转卡上不起作用

java - 数组是复合数据类型,但是如何呢?

docker - SMTP 未配置,请检查您的 grafana.ini 配置文件的 [smtp] 部

css - Angular ngx-bootstrap - 如何制作一个又大又宽的模态