Skip to content
← Back to Community
Why repldb
Profile icon
EpicGamer007

Repldb is amazing. it is completely free and integrated into repl. the problem though is that repl db has some values which it cannot parse, etc which becomes really annoying:

image

Do any of you know why this happens? Is there a way to prevent this?

Edit: For clarification: some values fail to be properly retrieved and this results with the program crashing.

Answered by 19wintersp [earned 5 cycles]
View Answer
Voters
Profile icon
GamingDimiGD
Profile icon
EpicGamer007
Comments
hotnewtop
Profile icon
19wintersp

I think it might just be a bad client which isn't URL-encoding characters. Here's my results, with the input character on the left, and what each client put it in the DB as:

Character@replit/databasereplitdb-clientbetter-repldb
aaaa
//*/*/
%(failed)*(failed)*(failed)*
??*?*?*
##*#*#*
=(blank)(blank)(blank)

Note that I also encountered issues with deleting keys, those are marked with an asterisk. As far as I have tested, you can fix all of these issues by URL-encoding your keys and values first, using encodeURIComponent, except for /, which should not be put in the database when using the official client or replitdb-client due to deletion issues.

Edit: added better-repldb

Profile icon
AmazingMech2418

@19wintersp This is true, but this issue, I believe, has to do with JSON.

Profile icon
19wintersp

@AmazingMech2418 It's stored as JSON?! I thought these issues stemmed from the usage of HTTP requests to update the database, and URLs being badly created... that's why I tested those characters specifically, and when compared to the API, the results make sense.

Profile icon
AmazingMech2418

@19wintersp Yeah. LOL! It uses JSON instead of text for the Node version. That's why curl worked!

Profile icon
19wintersp

@AmazingMech2418 What? I'm confused... what's using JSON? Does ReplDB have a JSON API?

Profile icon
AmazingMech2418

@19wintersp The clients use JSON. At least repldb-client and @replit/database which are the same thing.

Profile icon
19wintersp

@AmazingMech2418 As in, internally? I'm going to look at the source...

Profile icon
AmazingMech2418

If you're referring to Repl.it's Node implementation, it uses JSON. It can't parse a JSON input that isn't JSON. Try just using @coder100 's implementation or make your own! Also, you can use encodeURIComponent and decodeURIComponent to sanitize different characters!

Profile icon
AmazingMech2418

@AmazingMech2418 The raw option it says also doesn't exist, so if you want that, you have to go into the module for ReplDB and make your own modification. LOL!

Profile icon
EpicGamer007

@AmazingMech2418 hmm, i actually do use coder100's implementation, @Coder100 can you make your replitdb-client use the encodeURIComponent and decodeURIComponent?

Profile icon
AmazingMech2418

@EpicGamer007 Are you sure? The issue seems to be in the following code which is @replit/database...

<removed because all you need is in the next code snippet>

Look specifically at this part:

try { // Try to parse as JSON, if it fails, we throw value = JSON.parse(strValue); } catch (_err) { throw new SyntaxError( `Failed to parse value of ${key}, try passing a raw option to get the raw value` ); }
Profile icon
AmazingMech2418

@EpicGamer007 Wait... @Coder100 's implementation is the same as @replit/database...

Profile icon
AmazingMech2418

@AmazingMech2418 Wait, does @Coder100 know about this? LOL!

Profile icon
AmazingMech2418

@EpicGamer007 Run require("@replit/database").toString() to test this.

Profile icon
EpicGamer007
Profile icon
AmazingMech2418

@EpicGamer007 https://repl.it/@AmazingMech2418/ReplDB-test#a Compare the files a and b. LOL! They are pretty much the same!

Profile icon
AmazingMech2418

@EpicGamer007 Literally, Repl.it reformatted @Coder100 's code and called it their own. LOL! I don't see any credit either!

Profile icon
AmazingMech2418

@EpicGamer007 What is this? StackOverflow?

Profile icon
EpicGamer007

@AmazingMech2418 wait, so who copied, coder or repl?

Profile icon
AmazingMech2418

@EpicGamer007 Actually, I just looked and @Coder100 's is actually a fork of https://github.com/mrlapizgithub/repl-it.js ! That one is contributed to by @amasad 's brother too and likely other members of the Repl.it team! And @Coder100 's post was created AFTER that was!

Profile icon
AmazingMech2418

@EpicGamer007 Wait, the mrlapizgithub was actually @Coder100 too. LOL! He just moved to cursorweb on GitHub though... So technically, Repl.it took it from @Coder100 ... Unless you count the contributions from masfrost and kochman. IDK...

Profile icon
Coder100

oh yeah masfrost specifically asked permission lol @AmazingMech2418

Profile icon
Coder100

it's all good, so here is what happened

  • old computer: (was mrlapizgithub)
    • initial development of lib
  • repl.it: acquired
  • mission complete time to abandon project
    @AmazingMech2418
Profile icon
AmazingMech2418

@Coder100 Ah... Okay. LOL!

Profile icon
Coder100
Profile icon
EpicGamer007

@Coder100 lol, i wish u can add the encode and decode URIComponent, it sucks that we have to do it manually :((