Strapi无法从托管在Digital Ocean上的现有MongoDB中加载集合

8

我正在使用Strapi创建一个新应用程序,尝试将其与托管在Digital Ocean上的MongoDB连接,但不幸的是,Strapi无法从现有的MongoDB获取集合。以下是我遵循的完整步骤,以实现Strapi与现有MongoDB的连接:

  • I have followed this guide step by step to create a Strapi Application: Quick_Start_Strapi

  • Although, I need to connect to my existing MongoDB which is hosted on Digital Ocean. So, as per Strapi documentaion, I have mentioned all the credentials ( host, port, username, password ) of my existing Database only on the creation of the Strapi Application.

  • In the last, when application is created successfully, I have switched my current directory to project directory and run the command:

    $ strapi start
    
  • I haven't faced any error in the terminal , consequently, that means

    The connection is successful

  • Then, I have registered myself through Strapi Register Panel.

  • After logging into the application, there is only one collection is shown on the Strapi Dashboard that is the "Users Collection". Strapi failed to load any collection from existing MongoDB. In terms of Strapi, it failed to load any Content-Types.
1个回答

8
为了从 mongodb 中获取所有已创建的集合,您首先需要添加 content-types
前往 http://localhost:1337/admin 并按照以下步骤操作(登录后)-
  1. 首先添加一个 Content Type

enter image description here

  1. Advance Section 中添加您的集合名称。它应该与数据库中的名称相同。(在 Base Section 中,您可以为此集合指定任何名称)

enter image description here

  1. 确保添加所有具有正确字段类型的字段

enter image description here

  1. 现在只需单击 Content Types 下的集合,即可获取来自数据库的所有记录。

enter image description here

我已经从 mongo shell 创建了这两个记录,并且它们显示在此部分中。

enter image description here

我确定您已经得到了答案

欲了解更多信息,请查看以下链接-

Strapi-Create-product

您还可以查看官方视频


这仍然是从现有MongoDB“恢复”数据的唯一方法吗? - OArnarsson

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接