ifNull() returns a fallback when the first argument evaluates to null or is absent. Unlike ifAbsent(), which only substitutes missing fields, ifNull() also replaces explicit null values stored on the document.
Import from the pipelines entry point:
js
import { ifNull, field, constant } from '@react-native-firebase/firestore/pipelines';js
import { getFirestore } from '@react-native-firebase/firestore';
import { execute, field, constant, ifNull } from '@react-native-firebase/firestore/pipelines';
const db = getFirestore('your-enterprise-database-id');
const snapshot = await execute(
db
.pipeline()
.collection('users')
.select(ifNull(field('displayName'), constant('Anonymous')).as('displayName')),
);
snapshot.results.forEach(row => {
console.log(row.data().displayName);
});js
field('displayName').ifNull(constant('Anonymous')).as('displayName');| Helper | Missing field | Explicit null on document |
|---|---|---|
ifAbsent | fallback | keeps null |
ifNull | fallback | fallback |
Use ifNull when you want one expression to cover both absent and null values.
See the firebase-js-sdk ifNull declaration for full overload signatures.

Core / App