简体   繁体   English

如何使用Firestore数据源配置回送4

[英]how to configure loopback 4 with firestore datasource

I am trying to configure loopback4 with firestore data source using loopback-connector-firestore connector. 我正在尝试使用loopback-connector-firestore连接器使用firestore数据源配置loopback4。 when i am trying to post it is showing error code 500 with Error: Internal Server Error. 当我尝试发布时,它显示错误代码500,错误为:Internal Server Error。 Please tell me where i am exactly doing wrong. 请告诉我我到底在做错什么。

It is simple. 很简单。

  1. First follow the steps to create datasource running the console command lb4 datasource . 首先,按照以下步骤运行控制台命令lb4 datasource创建数据lb4 datasource
  2. When the command line ask you for the connector select other . 当命令行要求您提供连接器时,请选择“ other
  3. When the command line ask you for the connector's package name paste this loopback-connector-firestore . 当命令行要求您提供连接器的软件包名称时,请粘贴此loopback-connector-firestore Please note that all connector for loopback 3 must work in loopback 4. 请注意,回送3的所有连接器必须在回送4中工作。
  4. Then you should use a service account. 然后,您应该使用服务帐户。 Go to Project Settings > Service Accounts and press the Generate new private key button, in the Google Cloud Platform Console. 转到“ 项目设置”>“服务帐户” ,然后在Google Cloud Platform控制台中按“ 生成新的私钥”按钮。 Generate a new private key and save the JSON file. 生成一个新的私钥并保存JSON文件。
  5. Then in the src/datasources project folder open your new datasourceName.datasource.json file and add the following keys that you can find in the downloaded JSON file from the Google Cloud Platform in the previous step: 然后在src/datasources项目文件夹中,打开新的datasourceName.datasource.json文件,并添加以下密钥,您可以在上一步中从Google Cloud Platform下载的JSON文件中找到以下密钥:
{
  "projectId": "",
  "clientEmail":  "",
  "privateKey": "",
  "databaseName": "Optional, Default: projectId"
}

That is all. 就这些。 Now, if you have models, repositories and controller previously created you can run npm start , open the explorer and test your endpoints. 现在,如果您具有先前创建的模型,存储库和控制器,则可以运行npm start ,打开资源管理器并测试端点。

Regards. 问候。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM