Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why ref.getCollections() is not recognized as a function?

I'm doing a website which store users data on cloud firestore. I use this to get all subcollections of a user document once:

db.collection('users').doc(userID).getCollections().then( collections => {
  /*I get my collections and I enjoy it :D*/
})

The problem is that this function is not recognized. I find this message on the console:

TypeError: db.collection(...).doc(...).getCollections is not a function

I know I could get the all subcollections otherwise but I want to save the maximum of readings because of de limited quota. All others firebase functions work in my project (like get() or set()) and getCollections() is in the documentation. Thank for your help !

like image 682
Pasteque Avatar asked Jan 27 '23 05:01

Pasteque


1 Answers

Google team was replaced method name from 'getCollections' to 'listCollections'. So you should update this method name again. Reference at here https://googleapis.dev/nodejs/firestore/latest/DocumentReference.html#listCollections

It works for me with these tool versions: firebase-tools v7.2.1, firebase-admin v8.3.0, firebase-functions v3.2.0.

like image 123
congpc87 Avatar answered Jan 29 '23 13:01

congpc87