Skip to content

Implements enum[]#482

Merged
micheleriva merged 8 commits intomainfrom
feat/enum-arr
Sep 19, 2023
Merged

Implements enum[]#482
micheleriva merged 8 commits intomainfrom
feat/enum-arr

Conversation

@allevo
Copy link
Copy Markdown
Contributor

@allevo allevo commented Sep 18, 2023

With this PR, I want to introduce the enum[] as the follower of #458

So,

const db = await create({
  schema: {
   colors: 'enum[]',
  },
})
await insertMultiple(db, [
  {colors: ['green', 'red'] },
  {colors: ['green'] },
  {colors: ['blue', 'white'] },
])

const resultContains = await search(db, {
  term: '',
  where: {
    colors: { contains: 'green' },
  }
}) // Expected 2 results: 1° and 2°
const resultIntersects = await search(db, {
  term: '',
  where: {
    colors: { intersects: ['red', 'blue'] },
  }
}) // Expected 2 results: 1° and 3°

This PR introduces contains, and intersects operators because they are more appropriate for arrays.

  • implementation
  • documentation
  • tests
  • facets for enum and enum[]
  • feedback

@vercel
Copy link
Copy Markdown

vercel bot commented Sep 18, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
orama-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 19, 2023 4:00pm

Copy link
Copy Markdown
Contributor

@micheleriva micheleriva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good to me. I just left a couple of small comments. Since we're operating on arrays, I would use a unique keyword contains, where the value is either polymorphic (string or array of strings), or monomorphic (contains must include an array of 1 element).

@allevo
Copy link
Copy Markdown
Contributor Author

allevo commented Sep 19, 2023

Implement just containsAll operator

Copy link
Copy Markdown
Contributor

@micheleriva micheleriva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. In the future we might want to add another PR to implement a function for intersection

@micheleriva micheleriva merged commit 40562cc into main Sep 19, 2023
@micheleriva micheleriva deleted the feat/enum-arr branch September 19, 2023 16:02
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.

2 participants