Strapi不会从Digital Ocean上托管的现有MongoDB加载集合 [英] Strapi is not loading the Collections from existing MongoDB hosted on Digital Ocean
问题描述
我正在使用Strapi创建一个新应用程序,并且尝试将其与托管在Digital Ocean上的MongoDB连接,但不幸的是 Strapi无法从现有MongoDB中获取集合.在这里,我要提到为实现Strapi与现有MongoDB的连接而执行的完整步骤:
-
我已按照本指南逐步创建了Strapi应用程序:
- 在
高级部分
中,添加您的收藏名称.它应该与数据库中的相同.(在Base部分
中,您可以为该集合指定任何名称)
- 确保添加所有具有正确字段类型的字段
- 现在,只需单击内容类型" 下的集合,即可从数据库中获取所有记录.
我已经从
mongo shell
创建了这两个记录,它们都在本节中显示.我确定您会得到答案
有关更多信息,请在下面查看这些链接-
您还可以看到官方视频
I am creating a New Application using Strapi and I have tried to connect it with my MongoDB which is hosted on Digital Ocean but unfortunately Strapi is not able to fetch the collections from existing MongoDB. Here, I am mentioning the complete steps that I have followed to achieve the connection of Strapi with the existing 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.
解决方案In order to get all the already created collection from mongodb, you have to first add
content-types
.Goto http://localhost:1337/admin and follow these steps ( after login )-
- First add a
Content Type
- In
Advance Section
, add your collection name. It should be the same as in the database.( In theBase Section
you can give any name to this collection)
- Make sure to add all of the fields with correct field-types
- Now just click on your collection under
Content Types
and you will get all of the records from the database.
I have created both of these records from
mongo shell
and they are showing in this section.I am sure you get your answer
For more, check these links below-
You can see also official video
这篇关于Strapi不会从Digital Ocean上托管的现有MongoDB加载集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- 在