Most developers who have done a decent amount of coding will tell you they've thrown out a lot of their code. I can say I've thrown out millions+ of lines of code in products that didn't make it, were rewritten, or were dumped. It doesn't really bother me, at least later, because I always learn from the experience, and many times a lot of the code is reusable to some extent. The knowledge still is reuseable :-)
I worked at IBM in 1984-ish with System R, a new relational database product later released as DB2. Relational databases in 1984 were THE new BIG thing. They were going to solve the world's problems! Haha. I was so enamored with System R, in my free time, I wrote my own SQL interface for Commodore 64. Yes, Commodore 64! It was cool to me, and while it was not the full set of functions, you could do selects, queries, and inserts. It was written in BASIC and was MOST painful. Ug! I still did it because relational databases were so cool. I never thought to make a product out of it and if I did it was not the right platform obviously. The Commodore 64 was the only computer I could afford back then.
“Many” databases later I wrote another one I called ringDB. This was effectively DynamoDB, a distributed hash key-value database that's on Amazon’s AWS right now. I wrote ringDB a few years before DynamoDB as nothing else existed other than relational databases at the time. Google Bigtable existed but I’m not sure of its availability and we were using AWS so it was not practical. EC2 machines at the time were also relatively new and super cool. The key for ringDB was to provide the uptime and quaternary redundancy needed for our solution. This took an extraordinary amount of work, particularly as this predates Docker/containers and required real machine management.
Once DynamoDB came out I gleefully cheered and immediately used it. I certainly didn't want to support the key-value ringDB database as that's not the main function of what we're trying to accomplish. So more code, testing code, management code went in the code-dumpster. But as an entrepreneur, especially in the computer science area, you have to do what you have to do.