【问题标题】:Can't find() records from Play! application using mongoDB无法从 Play 中找到()记录!使用 mongoDB 的应用程序
【发布时间】:2013-08-27 18:52:11
【问题描述】:

我处于学习曲线的低端,所以请原谅这个简单化的问题。

我已经设置了我的第一个 Play 应用程序并使用 mongoDB 数据库实现了他们的 TodoList 教程。我的代码基本上反映了这段代码:https://github.com/Mironor/Play-2.0-Scala-MongoDb-Salat-exemple.

应用程序工作正常,但是当我使用命令行时,我找不到任何记录:

$ mongo
> show dbs 
local   (empty)
todo    0.0625GB
> db.todo.find()
> db.todo.tasks.find()
>
  • 我知道todo 数据库是我想要的,因为当我删除它时,我的数据就会消失。
  • 我知道里面有记录,因为我可以在应用程序中看到它们
  • 我想我应该在db.todo.tasks 中找到这些记录,因为它是specified by the model

那么如何从命令行控制台找到这些记录呢?

【问题讨论】:

    标签: mongodb scala playframework playframework-2.0


    【解决方案1】:

    todo 是数据库,tasks 是集合。试试这个:

    > use todo;
    switched to db todo
    > db.tasks.find();
    

    在 MongoDB shell 中,需要 use 命令来选择您的数据库,然后才能查询集合。当您启动 shell 时,您可能从 test db 开始,因此无法从那里执行您的任务。

    【讨论】:

      猜你喜欢
      • 2020-09-02
      • 1970-01-01
      • 1970-01-01
      • 2021-05-17
      • 2019-09-18
      • 2021-10-26
      • 2015-01-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多