Import query for both Realtime Database and Firestore Firebase web v9

When importing the query function for Firebase Realtime DB and Firestore, I noticed both query functions have the exact same name.

import { query } from "firebase/database";
import { query } from "firebase/firestore";

This is mentioned here and here in the documentation.

Is this the same function from both places? If not, should I just alias the import of one of the functions?

>Solution :

You can set an alias for one of the imports. Try:

import { query } from "firebase/database";
import { query as fireQuery } from "firebase/firestore";

const firestoreQuery = fireQuery(...)

Leave a Reply