Strapi不会从Digital Ocean上托管的现有MongoDB加载集合 [英] Strapi is not loading the Collections from existing MongoDB hosted on Digital Ocean

查看:49
本文介绍了Strapi不会从Digital Ocean上托管的现有MongoDB加载集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Strapi创建一个新应用程序,并且尝试将其与托管在Digital Ocean上的MongoDB连接,但不幸的是 Strapi无法从现有MongoDB中获取集合.在这里,我要提到为实现Strapi与现有MongoDB的连接而执行的完整步骤:

  • 我已按照本指南逐步创建了Strapi应用程序:

    1. 高级部分中,添加您的收藏名称.它应该与数据库中的相同.(在 Base部分中,您可以为该集合指定任何名称)

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

    1. 现在,只需单击内容类型" 下的集合,即可从数据库中获取所有记录.

    我已经从 mongo shell 创建了这两个记录,它们都在本节中显示.

    我确定您会得到答案

    有关更多信息,请在下面查看这些链接-

    Strapi创建产品

    您还可以看到官方视频

    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 )-

    1. First add a Content Type

    1. In Advance Section, add your collection name. It should be the same as in the database.( In the Base Section you can give any name to this collection)

    1. Make sure to add all of the fields with correct field-types

    1. 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-

    Strapi-Create-product

    You can see also official video

    这篇关于Strapi不会从Digital Ocean上托管的现有MongoDB加载集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆