How to get only special field data firebase realtime database react native

Viewed 234

I am developing react native project using firebase as backend. And I am using firebase realtime database for saving user information now. I want to get only special field from realtime database. For example, I want to get only user information that email is "devsmith@gmail.com" like following image. Please help me. Thanks.

firebase data structure

2 Answers

You should use @react-native-firebase/database to get your user's data

(doc in Realtime Database section => https://rnfirebase.io)

You should use react native firebase

The specific answer is in the Query section:

You will have to use the where operator like so :

import firestore from '@react-native-firebase/firestore';

// ...

firestore()
  .collection('user')
  // Filter results
  .where('email', '==', 'devsmith@gmail.com')
  .get()
  .then(querySnapshot => {
    /* ...do what you want with this querySnapshot */
  }
Related