问题
I've been using the firebase npm package to primarily interact with my Cloud Firestore + Authentication.
I want to use the listDocuments method on a collection, but this doesn't seem to exist in when I have:
import * as firebase from "firebase";
import "firebase/firestore";
const db = firebase.initializeApp(...).firestore();
db.collection("users").listDocuments()
And it says that listDocuments() is not a function.
I've tried also installing @google-cloud/firestore npm package but that seems to be throwing all sorts of error.
Should I be using @google-cloud/firestore, or is this a shortcoming of the firebase package?
回答1:
"@google-cloud/firestore" is for nodejs backends and will not work in a web browser. "firebase" is for JavaScript web frontends. They have different APIs and capabilities by design, but you can't necessarily force one to work in an environment where it was not designed to work.
来源:https://stackoverflow.com/questions/64673897/listdocuments-exist-in-google-cloud-firestore-but-not-firebase-npm-module-what