Currently, I am in the process of developing a mobile app using React Native and Firebase. My main focus right now is on accessing document data without explicitly specifying the ID, unlike the method shown below:
const docRef = db.collection('vehicle').doc('2l3bcSGs2vZBIc3RODwp').get()
In this example, the ID "2l3bcSGs2vZBIc3RODwp" is used as a direct parameter in the docRef method. However, my goal is to retrieve the ID dynamically without hardcoding it.
Here is the updated configuration for Firebase:
import { initializeApp } from "firebase/app";
import { getAuth,initializeAuth ,getReactNativePersistence} from "firebase/auth";
import { getFirestore } from "firebase/firestore";
import ReactNativeAsyncStorage from '@react-native-async-storage/async-storage';
//config key
const app = initializeApp(firebaseConfig);
initializeAuth(app, {
persistence: getReactNativePersistence(ReactNativeAsyncStorage)
});
const database = getFirestore(app);
const auth = getAuth(app);
export{auth,database};
If anyone has any suggestions on how to modify the method to achieve this dynamic retrieval of document data, please let me know! Thank you.