adminjs icon indicating copy to clipboard operation
adminjs copied to clipboard

How can I query a record or a list of records with exact matching property values?

Open eakenbor opened this issue 1 year ago • 1 comments

Contact Details

No response

What happened?

I want a situation where only the record or records with the exact property match are returned, instead of those with partial match. For instance, if a record has a property name "field1" and the property value for that that "field1" is "abcdef". If the input value is "abc", that record should not be returned. It should only be returned when the input value is exactly "abcdef".

What I did below does not work. Please how can I achieve this?

const api = new ApiClient()
  api
      .resourceAction({
        resourceId: 'User',
        actionName: 'search',
        query: email,
        params: {
          'filters.email': props.record.params.email
        }
      })
.then(...)

Bug prevalence

Every time

AdminJS dependencies version

"adminjs": "^7.0.5",

What browsers do you see the problem on?

No response

Relevant log output

No response

Relevant code that's giving you issues

No response

eakenbor avatar Apr 09 '24 17:04 eakenbor

Hey! I had a similar issue and found the solution after lots of debugging.

api.resourceAction({
  resourceId: "User",
  actionName: "list",
  params: {
    "filters.email": props.record.params.email,
  },
});

That should do the trick.

noftasmos1998 avatar Aug 26 '24 21:08 noftasmos1998