Firebase get document


#1

Is it possible to make a get request to a specific document in firebase. I know I can make a query. But all already got all the info to make a request for a specific document.
I know this is possible in Ruby with the Ruby client for firebase. But I can’t figure out to make the request in react studio.

If I look on firebase website it should look something like this:

let cityRef = db.collection(‘cities’).doc(‘SF’);
let getDoc = cityRef.get()
.then(doc => {
if (!doc.exists) {
console.log(‘No such document!’);
} else {
console.log(‘Document data:’, doc.data());
}
})
.catch(err => {
console.log(‘Error getting document’, err);
});


#2

Hi, currently you cannot refer to single document by creating a path into document but we’ll check if it is possible to implement into plugin. I guess it could works so that you simply build the full document path into Collection id field and it would return document as row in Data sheet.

Do you have any field in Document which you could use for querying specific document into Data sheet? The document ID is not field so one cannot use that in the query.


#3

I am able to make it with a query. I would just preferer to make it with a direkt link to the document.


#4

Ok it’s definitely a bit cleaner solution but with current plugin you need to either edit the plugin code to support direct path to document or do it via query.


#5

Just a heads up on this matter. With the latest Firebase plugin you can refer to single document with path.