Strapi is not loading the Collections from existing MongoDB hosted on Digital Ocean

让人想犯罪 __ 提交于 2021-02-19 01:24:39

问题


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.

回答1:


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



来源:https://stackoverflow.com/questions/51171858/strapi-is-not-loading-the-collections-from-existing-mongodb-hosted-on-digital-oc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!