Skip to content

query() api, chaning vs options #12

@Raynos

Description

@Raynos

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']
  })

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions