的Firestore docs只显示了如何设置使用firebase-admin
公司的FireStore,这似乎对我来说,基本上是一个服务器端解决方案。即使我们谈论的是使用云功能,这仍然是一个小型的服务器与浏览器和数据库之间的一个额外的抽象层。我正试图弄清楚如何进行类似的设置,直接从浏览器代码访问实时数据库。如何建立云公司的FireStore静态托管网站
在5分钟时为YouTube: Getting Started With Cloud Firestore on the Web | Complete Tutorial由谷歌提供的,我清楚地看到正在使用这种类型的配置,除了现在初始化程序之后,我们称之为firestore()
方法,而不是database()
方法来获取根引用。
我已经重新启动了启动firestore的项目,并且已经将项目规则设置为允许任何人访问它。但对我来说是不包括在我的火力实例firebase()
方法。
const firebase = require('firebase')
const config = {
apiKey: 'long_ugly_string',
authDomain: 'my_app_id.firebaseapp.com',
databaseURL: 'https://my_app_id.firebaseio.com',
projectId: 'my_app_id',
}
firebase.initializeApp(config)
console.log(firebase.firebase) // undefined
const firestore = firebase.firestore() // TypeError: firebase.firestore is not a function
我也尝试创建一个100%全新的项目,以确保问题不被旧的设置从实时数据库安装挥之不去所致。但我对这个新项目有同样的问题。我的火力实例结束了一个database()
方法,但没有firestore()
方法。
您使用的是哪个版本的Firebase? –
的火力文档展示了如何使用几种不同的语言。服务器端JavaScript显示在“Node.js”选项卡下。您应该查看客户端JavaScript的“Web”选项卡。确保您[使用正确的图书馆版本](https://firebase.google.com/docs/firestore/quickstart#set_up_your_development_environment) – Sidney