Python 通过“firebase”和“gcloud”启动firestore emulator之间的区别?
通过以下方式启动firestore emulator有什么区别:Python 通过“firebase”和“gcloud”启动firestore emulator之间的区别?,python,firebase,google-cloud-platform,google-cloud-firestore,gcloud,Python,Firebase,Google Cloud Platform,Google Cloud Firestore,Gcloud,通过以下方式启动firestore emulator有什么区别: firebase emulators:start --only firestore 以及: 这两个选项都允许我的python应用程序实现与数据库的连接,如下所示: import google from google.cloud import firestore os.environ["FIRESTORE_EMULATOR_HOST"] = "localhost:8081" os.envi
firebase emulators:start --only firestore
以及:
这两个选项都允许我的python应用程序实现与数据库的连接,如下所示:
import google
from google.cloud import firestore
os.environ["FIRESTORE_EMULATOR_HOST"] = "localhost:8081"
os.environ["FIRESTORE_EMULATOR_HOST_PATH"] = "localhost:8081/firestore"
os.environ["FIRESTORE_HOST"] = "http://localhost:8081"
credentials = mock.Mock(spec=google.auth.credentials.Credentials)
client = firestore.Client(credentials=credentials)
我自己注意到的一个区别是,firebase
似乎尊重我的firebase.json
,特别是指定的主机端口,如下所示:
{
"emulators": {
"firestore": {
"port": "8081"
}
}
}
另一方面,
gcloud
忽略firebase.json
,而是选择一个随机端口,除非我通过--host port
显式传递端口。这是这两个工具之间更大区别的一部分吗?还有什么其他区别吗?我一直在查看这两个工具的文档,它们做的事情几乎相同
使用可以启动多个Firebase产品的模拟器,而允许启动GCP模拟器。Firestore只是他们共同拥有的一种产品,因此他们的效用应该相同或相似
关于功能差异,firebase
提供了--import
和--export-on-exit
标志,允许您在模拟会话之间保存和恢复数据。它还提供了一种可视化用户如何处理当前查询的方法
除了这些功能外,我还要注意设置端口和规则文件的不同方法:
使用该文件firebase模拟器
使用标志和来实现相同的功能gcloud beta模拟器
gcloud
,请使用它
{
"emulators": {
"firestore": {
"port": "8081"
}
}
}