Complete the code to initialize Firebase for a specific tenant.
const app = initializeApp({ projectId: [1] });Each tenant should have its own project ID to isolate resources.
Complete the code to set Firestore rules for tenant data isolation.
match /databases/{database}/documents {
match /users/{userId} {
allow read, write: if request.auth.token.[1] == userId;
}
}The 'uid' in the auth token matches the user ID to ensure users access only their data.
Fix the error in the Firestore query to fetch tenant-specific data.
const query = firestore.collection('orders').where('tenantId', '==', [1]);
The field name in the database is 'tenantId' without quotes in the query method.
Fill both blanks to create a Firestore document path for tenant data isolation.
const docRef = firestore.collection([1]).doc([2]);
The collection is 'tenants' and the document is the specific 'userId' to isolate tenant data.
Fill all three blanks to define a Firestore security rule for multi-tenant data access.
match /[1]/{docId} { allow read, write: if request.auth.token.[2] == resource.data.[3]; }
The rule matches the 'tenants' collection and checks that the auth token's 'tenantId' matches the document's 'tenantId' field.