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
- Hi Folks, Database Writing Issue
Hey Folks im trying to get logging setup on my website but im getting an error, i dont have any document id and i think this is the issue but i havent got the f...
- Auth not working on expo react native
I'm trying to launch a development server with expo go and appwrite as a backend. On my windows pc, I've got a local docker instance of appwrite running as my b...
- Bulk delete failed with 401
- I created a transaction to bulk delete rows in a table has `done` equal `true` follow documentation. But when run, it returns 401 unauthorized error as screen...