
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
- Console create row ui not passing ID.uni...
I'm getting an error saying the id is already used but it should be created with ID.unique() it doesn't seem to be reading the row ID field at all. I can't get ...
- Still getting ServiceContextModule linke...
Hey team - I'm still getting ServiceContextModule linker errors even after updating to SDK 13.2.2. Error: - Undefined symbol: static ServiceContextModule.Servi...
- Permissions in create_operations() Pytho...
How can I set permissions for `create_operations()`? What even is the correct way to use permissions in Python (using SDK version 13.4.1) ? In my cloud functio...
