Skip to content

I can't filter by list function with prefix #49

Description

@hyhkjiy

Description

When I use the list method and only pass the callback function, I can get all the key-value pairs in the database.
But when I use the prefix, I only get an empty array.
I'm sure there are keys with prefixes in the database.
In order to facilitate the demonstration of the problem, I wrote a simple demo:

import hypertrie from 'hypertrie'
import dotenv from 'dotenv'
import path from 'path'


dotenv.config()

let dbPath = path.join(process.env.EXPORT_FOLDER, process.env.STORE_FILE)

let db = hypertrie(dbPath, { valueEncoding: 'json' })

let key = 'p:4f7bbe1d-fe4a-45cb-bdf4-f2e67fefdb84'

db.put(key, { 'test': 'aaa' }, err => {
    if (err) {
        console.error(err)
    } else {
        db.get(key, (err, value) => {
            if (err) {
                console.error(err)
            } else {
                console.info('get success', value)
            }
        })

        db.list('p', {}, (err, value) => {
            if (err) {
                console.error(err)
            } else {
                console.info('list p success', value)
            }
        })

        db.list((err, value) => {
            if (err) {
                console.error(err)
            } else {
                console.info('list success', value)
            }
        })
    }
})

terminal print:
image

Software info:

image

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions