Skip to content

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

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

Open
hyhkjiy opened this issue Mar 30, 2022 · 0 comments
Open

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

hyhkjiy opened this issue Mar 30, 2022 · 0 comments

Comments

@hyhkjiy
Copy link

hyhkjiy commented Mar 30, 2022

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

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

No branches or pull requests

1 participant