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
- Error: User (role: guests) missing scope...
I want to send a verification code to the user and the given phone number and check it and create a session right after the user entered the secret. For me that...
- Sign In With Apple OAuth Help
Hi All! I've got a flutter & appwrite app which Im trying to use sign in with apple for. I already have sign in with google working and the function is the sam...
- Type Mismatch in AppwriteException
There is a discrepancy in the TypeScript type definitions for AppwriteException. The response property is defined as a string in the type definitions, but in pr...