I am creating some similar decks that use the exact same long text strings in some fields, and could take a lot of storage. So I thought of putting the data in a database (in the media folder) and only putting the keys in the field to save space. And then pull the text string according to that field, something like this:
Get String At {{keyField}}
Is this possible? And what is the syntax to do it?
I’m not entirely sure this is possible as you’ve conceived it because of security issues within a browser (or browser-like) context. Someone would have to comment on whether there’s a workaround for that; I don’t know. But there are other ways to go about it. You could run a server and make API calls to your SQLite database from Javascript in your card template. I’ve done this with a Flask app that receives API calls from my cards. (Different purpose than yours, but same concept.)
Thank you both!
Since using an SQLite database doesn’t seem to be possible, I thought of a different approach.
I put the data in a JavaScript array. It is essentially the same concept.
It seems however that Anki Desktop (Windows 10 Version 2.1.43 ) doesn’t work well with JS for some reason. The script is being executed on the front side of the first card only (in a session)!
I confirmed that it works perfectly on AnkiDroid for every single card.
Edit: I found the reason it didn’t work on desktop; I should have used var instead of const for the array.