#Get one KV entry by cursor

3 messages · Page 1 of 1 (latest)

west sandal
#

Hi,

is there a possibility to get one KV entry by cursor? Or it is possible to convert the cursor to a KV key?

Thanks

river dragon
#

Not exactly knows your intention, but KV's list returns an iterator with option to limit the result. In your case, you can set limit to 1.

Then use the cursor of the iterator to advance.

#
let cursor;
let iter = db.list({ prefix: ["users"] }, { limit: 1, cursor });
cursor = iter.cursor;

iter = db.list({ prefix: ["users"] }, { limit: 1, cursor, };