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

Getting error when using $re (mongodb) #613

Closed
iamomiid opened this issue Jun 21, 2020 · 2 comments
Closed

Getting error when using $re (mongodb) #613

iamomiid opened this issue Jun 21, 2020 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@iamomiid
Copy link
Contributor

iamomiid commented Jun 21, 2020

Describe the bug
Getting MongoError: unknown operator: $re when performing a simple regex find like so:

this.repo.findOne({ name: { $re: 'test' } })

To Reproduce
Steps to reproduce the behavior:

  1. Use one the example
  2. Perform a simple regex search

Expected behavior
To return documents matching the input regex.

Versions

Dependency Version
node 14.3.0
typescript 3.9.4
mikro-orm 3.6.15
@iamomiid iamomiid added the bug Something isn't working label Jun 21, 2020
@B4nan
Copy link
Member

B4nan commented Jun 21, 2020

That operator is designed for SQL, you don't need it in mongo, just pass the regexp instance directly:

this.repo.findOne({ name: /test/ } })

(sure we can make it compatible with mongo too)

B4nan added a commit that referenced this issue Jun 21, 2020
@B4nan
Copy link
Member

B4nan commented Jun 21, 2020

Closing as fixed in v4 via 27e7242

@B4nan B4nan closed this as completed Jun 21, 2020
B4nan added a commit that referenced this issue Aug 2, 2020
B4nan added a commit that referenced this issue Aug 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants