listDocuments exist in @google-cloud/firestore but not firebase npm module: what's the difference?

放肆的年华 提交于 2021-01-29 07:14:39

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!