organizationNumber: 111111111
organizationName: Company A
Address: Some address
tenantId: <link to an autogenerated ID from tenants>
Name: User A
Email: some...@gmail.com
tenantId: <link to an autogenerated ID from tenants>
orderDetails: some order details, can be more fields here
service cloud.firestore {
match /databases/{database}/documents {
match /tenants/{tenantId} {
allow read: if exists(/databases/$(database)/documents/users/$(request.auth.uid)) &&
get(/databases/$(database)/documents/users/$(request.auth.uid)).data.tenantId == tenantId
}
}
}
// Create a reference to the tenants collection
var tenantsRef = db.collection("tenants");
// Create a query against the collection.
var query = tenantsRef.where("organizationNumber", "==", "<example-organization-id>").limit(1);
service cloud.firestore {
match /databases/{database}/documents {
match /tenants/{tenantId} {
// Allow read access on to tenants document if tenant.userId is user's id
allow read: if resource.data.userId == request.auth.uid;
}
}
}
/organizations/123abc/
users: {
j324oior: 'some.role'
}

users: {
ezri....: 'ADMIN', // Role as a string
sT0z...: { role: 'EDITOR', joinedOn: '30 Jan 2019' } // or as object
}firestore.doc('/tenants/123').update({
'users.ezri1231': 'EDITOR'
})You should reconsider why they need to be in a document, rather than each object being their own document.
Cloud Firestore's limits are listed in the documentation." - Dan McGrath on SO
--
You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/0POxgDoQgVA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/09521395-6faa-4bcf-a065-b34029920d63%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


