Create:
let babyResult: Baby = try await database.createDocument(
databaseId: R.Database.babyBottleDbId,
collectionId: R.Database.babyCollectionId,
documentId: babyId,
data: data,
permissions: [
Permission.read(Role.team(babyId)),
Permission.write(Role.team(babyId)),
Permission.delete(Role.team(babyId)),
Permission.update(Role.team(babyId))
], nestedType: Baby.self).data
Get:
func fetchBabies() async throws -> [Baby] {
try await database.listDocuments(
databaseId: Constants.Database.babyBottleDbId,
collectionId: Constants.Database.babyCollectionId,
nestedType: Baby.self
).documents.map { $0.data }
}
I can see the document and the permission are ok in the console
And my user has membership of the team of course
is it normal that the document ID is the same as the team ID ? (babyId)
Yeah creating a baby also create a team with the same id (easier for me)
(this allow users to manage the same baby if they are member of the same team)
func fetchBabies() async throws -> [Baby] {
let response = await database.listDocuments(
databaseId: Constants.Database.babyBottleDbId,
collectionId: Constants.Database.babyCollectionId,
nestedType: Baby.self
)
console.log(response)
}
Can you try this instead ? I think that the problem might be coming from the .map
Sorry, I proxy the request and I have printed the network response and Document is empty but total is 1 (see my first message)
Oh okk weird 🤔
maybe a bad migration? I can re-run the database migration just to see
maybe yeah, before that can you try to add user permission for this document ? see if it change anything ?
(in addition as the team permission)
yeah I've tried to add permission to my specific user, it didn't changed anything
well I have no idea sorry, maybe try to redo a migration
no effects 😦
Looks like Document Security is ignored only collection permission works
Update: adding a query limit fix the issue:
solution:
func fetchBabies() async throws -> [Baby] {
try await database.listDocuments(
databaseId: Constants.Database.babyBottleDbId,
collectionId: Constants.Database.babyCollectionId,
queries: [
Query.limit(100) // otherwise document are empty!
],
nestedType: Baby.self
).documents.map { $0.data }
}
That's super weird
Ok what is super weird is that I have another listDocument query with a limit, and if I don't put the same query limit value for the both request, it doesn't works
I think there is a really issue somewhere
Ya, there's some funky behavior with permissions at the moment. We're working through them ASAP
Thanks @Steven I’m using the query limite as workaround for now
We just released 1.3.2! See https://discord.com/channels/564160730845151244/636818236310159360/1101246221089263617. Thanks for your patience!
Recommended threads
- Failed to generate functions SSL
```appwrite-worker-certificates | Cannot renew domain (functions.domain.com) on attempt no. 9 certificate: Failed to verify domain DNS records. appwrite-worker...
- Query multi-tenant db with $permissions ...
I'm setting up a multi-tenant database with RLS enabled. My users my have permissions set for multiple Teams, and as such when they query the database with the ...
- Realtime for files() works almost well, ...
I have been trying to make use of realtime, today (14.03.26) I have pulled all the latest versions of docker images, and sdk available. Whats working: - Conn...