在Firestoresdk片段中找不到databaseURL
我在启用 Google Analytics 的情况下创建了一个云databaseURLFirestore,但在 Firestore SDK 代码段中没有找到该属性
这是 CDN:
<script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-app.js"></script>
<!-- TODO: Add SDKs for Firebase products that you want to use
https://firebase.google.com/docs/web/setup#available-libraries -->
<script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-analytics.js"></script>
<script>
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
var firebaseConfig = {
apiKey: "AIzaSyAx5I8j6ZkqCxQ3k1UgGkL5BuwhVK5xezA",
authDomain: "ninja-firestore-tut-c5340.firebaseapp.com",
projectId: "ninja-firestore-tut-c5340",
storageBucket: "ninja-firestore-tut-c5340.appspot.com",
messagingSenderId: "326083693415",
appId: "1:326083693415:web:5a8e21d6a0d90fec9d7dc2",
measurementId: "G-2D61GV0P3Q"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.analytics();
</script>```
回答
该databaseURL属性适用于您可能尚未创建的 Firebase 实时数据库。databaseURL但是,使用 Firestore 不需要该属性,因此您应该能够仅使用您拥有的配置数据来访问它。事实上,对于 Firestore,您只需要projectId属性即可。
- Until a few months ago a Realtime Database instance was auto-created for each project. That's not the case anymore, so that's why it's not in your config anymore. But your Firestore access should work fine without it. If not, please post a new question with details about that problem. If my answer was useful, click the upvote button (▲) to the left of it. If it answered your question, click the checkmark (✓) to accept it. That way others know that you've been (sufficiently) helped. Also see [What should I do when someone answers my question?](https://stackoverflow.com/help/someone-answers)