Level / level

Universal abstract-level database for Node.js and browsers.
MIT License
1.55k stars 106 forks source link

Find specific key createReadStream #203

Closed hanumanjiblog closed 3 years ago

hanumanjiblog commented 3 years ago

Not able to find specific part of the key "uid3" using createReadStream

const level = require('level') const db = level('my-db') setImmediate(async () => { await db.put('type:user:uid1', 'value') await db.put('type:user:uid2', 'value') await db.put('type:user:uid3', 'value') // not working- db.createReadStream({ gte: '\xff:uid3' }).on('data', function (data) { console.log(data.key, '=', data.value) }) // not working- db.createReadStream({ gte: 'uid3' }).on('data', function (data) { console.log(data.key, '=', data.value) }) });

vweevers commented 3 years ago

Keys are sorted in lexicographic order. In \xff:uid3, the first character (or byte) is greater than the first character of any of your keys (t) so it will not match anything. Same goes for uid3: that's u vs t.

hanumanjiblog commented 3 years ago

So please tell me how to find uid3 without using 'type:user:'

hanumanjiblog commented 3 years ago

If i use "t" it also not working please tell how to find this key.

omymy1 commented 3 years ago

Yes, also I tried this but it not working, that us very important feature, @vweevers Please try to solve/answer this.

vweevers commented 3 years ago

Closing because:

  1. The initial question is vague, provides no details beyond "it's not working" and could use code formatting for readability.
  2. My answer should be enough to get you going. If it's not, then GitHub is not the right place to ask.
  3. The follow-up question has a demanding tone, does nothing to clarify the initial question or why type:user: doesn't work.