Types
Firebase-specific types exported by MSR Firebase.
Table of contents
EntityService types
EntityService exports the UpdateFunction<T> callback type and ModificationResults result shape.
export type UpdateFunction<T> = (entity: T) => boolean;
export type ModificationResults = {
skipped: string[];
updated: string[];
};
The callback passed to updateAll() mutates an entity and returns true when it should be saved. The result contains Firebase keys for updated and skipped entities.
import { EntityService, type IEntity, type ModificationResults } from '@migration-script-runner/firebase';
import type { Database } from 'firebase-admin/database';
interface User extends IEntity {
name: string;
}
async function updateUsers(database: Database): Promise<ModificationResults> {
const users = new EntityService<User>(database, 'users');
return users.updateAll((user) => {
if (user.name !== 'Alice') return false;
user.name = 'Alicia';
return true;
});
}
See the EntityService API for all methods, and Interfaces for IFirebaseDB and IEntity.