typeorm-cursor-pagination icon indicating copy to clipboard operation
typeorm-cursor-pagination copied to clipboard

unknown type in cursor for branded ids

Open rares-lupascu opened this issue 4 years ago • 4 comments
trafficstars

Hi

So my ids are branded to avoid miss-assignments What that means is that instead of passing string is the type (uuid format) i am passing my custom type which is UserId It looks like this:

interface ConversationId extends String {
    _conversationBrand: string;
}

so in this case I cannot create the pagination object:

"unknown type in cursor: [object]bee5b8e2-80ab-4ba8-b762-02c3e7337ca5"

any suggestion to avoid this?

thanks

rares-lupascu avatar Jul 17 '21 08:07 rares-lupascu

i think i have a fix for this adding this in utils.ts after line 28 worked for me:

if (typeof value.toString === 'function') {
  return value.toString();
}

rares-lupascu avatar Jul 17 '21 08:07 rares-lupascu

  • this for the case 'object' when decoding the curos ... utils.ts line 43
if (typeof value.toString === 'function') {
   return value.toString();
}

i can create a PR if it helps

rares-lupascu avatar Jul 17 '21 09:07 rares-lupascu

Hi @rares-lupascu

Thanks for your feedback and propose your use case, the PR is welcome!

benjamin658 avatar Jul 17 '21 16:07 benjamin658

done #35

rares-lupascu avatar Jul 17 '21 18:07 rares-lupascu