It seems that a function of LevelDBIindex.ts will apply a FULL SCAN :
// Full scanasyncsearchThoseMatching(search:string):Promise<OldIindexEntry[]>{constuidKeys=awaitthis.indexForUid.findAllKeys();constpubKeys=awaitthis.findAllKeys();constuids=uidKeys.filter((u)=>u.includes(search));constpubs=pubKeys.filter((p)=>p.includes(search));constuidIdentities=awaitPromise.all(uids.map(async (uid)=>OldTransformers.toOldIindexEntry(reduce(awaitthis.findByUid(uid)))// Why this merge ?));constpubIdentities=awaitPromise.all(pubs.map(async (pub)=>OldTransformers.toOldIindexEntry(reduce(awaitthis.findByPub(pub)))// Why this merge ?));returnuidIdentities.filter((u)=>u.pub).concat(pubIdentities.filter((p)=>p.pub));}
I want to rewrite this code, in a new function a searchByPubkey(), but i don't understand why the reduce() function is used here : it will merge all identities founded by pubkey) in one object ??
If i look inside the SQLLite implementation, this merge was not done :
asyncsearchThoseMatching(search:string):Promise<OldIindexEntry[]>{return (awaitthis.find("SELECT * FROM iindex WHERE pub = ? OR uid = ?",[search,search,])).map(OldTransformers.toOldIindexEntry);// Result was not merged !?}