Closed poofy25 closed 2 months ago
As per the docs, only the following arguments are provided to the read function: req
and id
, but data
appears to be also there.
On the same beta as yours, this:
access: {
read: ({ id, data }) => {
console.log(id, data)
return true
}
}
Results in undefined undefined
when I'm in the collections view and then it's not undefined (it logs the id
and data
) when I open a single document. This is expected behaviour. Are you getting undefined
when you open the document as well?
Have you tried using a Where
query instead of returning a boolean? Something like:
read: ({ req: { user } }) => {
return {
id: {
in: user?.courses,
},
}
}
Then in your Users
collection, the relationship field courses
needs to have hasMany: true
and maxDepth: 0
as to make the user.courses
an array of IDs.
This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.
Link to reproduction
No response
Environment Info
Describe the Bug
I have a Users collection that have a relationship to this Courses collection and I need to check if the user has the fetched course included in the relationship.
But in the access read function the id and data of the document always return undefined, I also saw some other people having the same issue on discord.
Reproduction Steps
Create a collection and log the id and data parameters to the console.
Adapters and Plugins
No response