I don’t need to number these, do I?

I wanted to work on the plated recipe bulk import command I mentioned before, but, surprise-surprise, I had to work on something else first. This command needs to create a new database at runtime, something to put the plated recipes into, and it turns out, the database interface plugin for Tauri I’ve been using, tauri-plugin-sql isn’t up to it.

tauri-plugin-sql is a thin wrapper around the sqlx library for rust. It lets you interface with databases just fine, but the databases have to be specified at compile time, in rust. Creating a new one after the app starts isn’t possible, so I had to write my own replacement: https://gitlab.com/dizzycodes/tauri-plugin-database

Unfortunately, I have very little experience in rust (basically the tiny tauri plugin I made last time I worked on mealplanner), so I have no idea how well it’s coded. But it does work.

It’s basically the same as tauri-plugin-sql, except the load() function accepts migrations and will create the database connection pool there, rather than on application startup.

There’s also one other difference, tauri-plugin-sql stores the collection of database connection pools it creates behind a Mutex, so every SQL query ends up contending for this lock, despite connection pools (to my knowledge) already being thread safe. I changed this to use a read-write lock. Given writes only happen on database loading, it should be far more efficient.

Anyway, it’s kind of an annoying thing to lose two days to work I shouldn’t have to do, I do wish Tauri employed SOLID principles more. But it did give me an opportunity to dig further into rust, I understand the language much better now. And I can confidently say, I do not like it at all (it’s like a bunch of developers got together, made a list of things they didn’t like about C++ like templates & memory management, and then created a language that made it all even more complicated).

Now I can finally work on my app. Hopefully.