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

query() api, chaning vs options #12

Open
Raynos opened this issue Feb 15, 2020 · 1 comment
Open

query() api, chaning vs options #12

Raynos opened this issue Feb 15, 2020 · 1 comment
Assignees
Labels
good first issue Good for newcomers

Comments

@Raynos
Copy link
Contributor

Raynos commented Feb 15, 2020

Currently you can do

const iterator = table
  .query(`hash = N(songs) AND begins_with(range, S(moth))`)
  .filter(`contains(artists.name, S(danzig)`)
  .properties('artists.weight', 'artists.height')

First of all the method is properties but the documentation is projection expression; Can we change the method to .projection() ?

To apply filters and properties we chain onto the iterator. This mutates the query()

To me its confusing what the behavior of the following code is

const iterator = table
  .query(`hash = N(songs) AND begins_with(range, S(moth))`)

const filterItr = iterator
  .filter(`contains(artists.name, S(danzig)`)

const projetedItr = filterItr
  .properties('artists.weight', 'artists.height')

await iterator.next()
await filterItr.next()
await projectedItr.next()

Instead of using mutating method & chaining would it be simpler to just pass an options object to query()

const iterator = table
  .query(`hash = N(songs) AND begins_with(range, S(moth))`, {
    filter: `contains(artists.name, S(danzig)`
    properties: ['artists.weight', 'artists.height']
  })
@heapwolf
Copy link
Member

yeah, I think this is a good change. perhaps the first positional argument could be String|Object, if its an object it takes { condition, filter, projection } otherwise its just the condition

@heapwolf heapwolf self-assigned this Feb 15, 2020
@heapwolf heapwolf added the good first issue Good for newcomers label Feb 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants