I realise this question is marked as a duplicate - but I think this question is more comprehensive and easier to understand, and therefore more likely to help others. (^__^)
I have read about reading data from Firebase realtime database. https://firebase.google.com/docs/database/admin/retrieve-data
What I have not found is any documentation on how to control what data gets returned from the read query.
Consider the following structure:
-users
-EiYu7OWooToo6noo
alias: "Kermit"
createdAt: 1538330532000
firstName: "Kermit"
surName: "Frogman"
pictureURL: "/imgs/kermit.png"
phonePrimary: "555-1234"
email: "kermit@themuppetshow.com"
-myBooks
-A1234567890
title: "Frogs 101"
...
Is there a way to tell Firebase realtime database to only return some of the document data?
This code returns the entire document:
var ref = db.ref(`users/${uid}`);
ref.once("value", (snapshot) => {
console.log(snapshot.val());
}, function (errorObject) {
console.log("The read failed: " + errorObject.code);
});
Would it be possible to only get a partial document, for example:
{
alias: "Kermit"
firstName: "Kermit"
}
My reasoning is that this would be a huge performance gain when reading large amount of data. But is it possible?