AdminJS Filter resources with mongodb object ID

50 Views Asked by At

is there a way to show only resources from a given user?

Ive a User Schema and a Items Schema with Ref on User. I only want to show items from the currentAdmin.

Here is my current code:

const customBefore = (request: { query: any }, context: any) => {
  const {query = {}} = request
  const newQuery = {
    ...query,
    ['filters.user']: context.currentAdmin._id
  }

  request.query = newQuery

  return request
}

Im getting TypeError: Cannot read properties of null (reading 'type') error

0

There are 0 best solutions below