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

fix(query): handle array fields in $in operator #1277

Merged
merged 1 commit into from Jun 22, 2022
Merged

Conversation

farnabaz
Copy link
Member

πŸ”— Linked issue

resolves #1272

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

The current behavior of $in operator was wrong, because it tried to check equality between item and condition.
For example in this sample:

const item = { tags: ['foo', bar'] }
const cond = { tags: { $in: [ 'foo'] }

match(item, cond)

$in operator was checking if 'foo' === ['foo', 'bar'].

But the correct behavior for arrays is not equality check, it is $contains check.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@netlify
Copy link

netlify bot commented Jun 21, 2022

βœ… Deploy Preview for nuxt-content ready!

Name Link
πŸ”¨ Latest commit 5a777e6
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt-content/deploys/62b1d45b1540110008bd48e3
😎 Deploy Preview https://deploy-preview-1277--nuxt-content.netlify.app
πŸ“± Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@farnabaz farnabaz merged commit 85ca12a into main Jun 22, 2022
@farnabaz farnabaz deleted the fix/-array-fileds branch June 22, 2022 11:22
@farnabaz farnabaz mentioned this pull request Aug 12, 2022
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 this pull request may close these issues.

$in operator support for matching values in an array
2 participants