Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to query firestore from the command line as admin

How do I authenticate as admin from the command line to dump out / query the data in my firestore? Example, I have a users collection where each document looks like:

{
  edit_count: 15
}

I simply want to print all these documents as json in my terminal.

I've used firebase-tools, but it looks like it's only supporting querying of the RTDB?

like image 461
astrojams1 Avatar asked Jan 30 '18 19:01

astrojams1


People also ask

How do I get data from firestore query?

How to get query data using firebase firestore? Simply, use a get() call! query. get().

How do I get data from Filesnapshot firestore?

A DocumentSnapshot contains data read from a document in your Cloud Firestore database. The data can be extracted with the getData() or get(String) methods. If the DocumentSnapshot points to a non-existing document, getData() and its corresponding methods will return null .


2 Answers

While waiting for firebase-tools to support more firestore commands, I wrote a basic firestore client that you might find useful:

https://github.com/sgarciac/fuego

like image 183
Galactus Avatar answered Sep 22 '22 23:09

Galactus


At the moment (July 2018) Firebase CLI supports database commands (get, set, push etc etc) only for the Realtime Database probably due to Firestore beeing in beta.

Hopefully it will support it later.

like image 25
giammin Avatar answered Sep 25 '22 23:09

giammin