Skip to content

ReadTransaction.scan ignores limit option when an indexName is provided #1039

@arv

Description

@arv

https://discord.com/channels/830183651022471199/1050431029602697226/1050431029602697226

In a useSubscribe query, I have the following:

const countWithoutIndex = (
    await txn
        .scan({
            limit: 1,
        })
        .entries()
        .toArray()
).length;

const countWithIndex = (
    await txn
        .scan({
            indexName: "foo",
            limit: 1,
            start: {
                key: ["bar"],
            },
        })
        .entries()
        .toArray()
).length;

I observed that countWithoutIndex is always 1 (respecting the limit option as expected), but countWithIndex is not 1. It seems that the scan iterator does start at the provided index value ("bar"), but it doesn't stop at the given limit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions