Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List action returns both records with status Active and Inactive when search only for Active #105

Open
geekyayush opened this issue Apr 29, 2023 · 1 comment · May be fixed by #106
Open

Comments

@geekyayush
Copy link

I have a number of records in my collection; some have "Active" in status property and others have "Inactive".

In AdminJS frontend, when I filter status field to show me only "Active" status records, it returns both Active and Inactive. For Inactive status filter, it works fine.

I believe the reason could be in file "src/utils/convert-filter.ts", line number 19.
Link; https://github.com/SoftwareBrothers/adminjs-mongoose/blob/master/src/utils/convert-filter.ts#L19

It's searching a property using regex, which returns both Active and Inactive since both values contain "Active".

Is there any workaround we can do to make sure only either Active or Inactive records get returned by the list action?

@hiteshbedre
Copy link

You can use symbols such as ^ and $ while regex matching.

^ asserts position at start of a line
$ asserts position at the end of a line

so the final pattern becomes: ^Active$

Here is the playground: https://regex101.com/r/QUhCxQ/1

@hiteshbedre hiteshbedre linked a pull request Apr 29, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants