Temporary Documents

Is there a built-in way to create temporary entities? Like entities wich are not stored in the database, but remains in memory for .update etc
C
Calego1,015d ago
There is! https://foundryvtt.com/api/abstract.Document.html#.create The second arg here is "context": https://foundryvtt.com/api/global.html#DocumentModificationContext So basically you can do this:
const tempItem = Item.create(data, { temporary: true });
const tempItem = Item.create(data, { temporary: true });
M
Magus1,015d ago
wow i thought it was a long shot ty! sadly... it does not work as I intended
M
Magus1,015d ago
No description
M
Magus1,015d ago
i cant use setflag nor update with a temporary journal =/
C
Calego1,015d ago
What are you attempting? If you know this information when the journal is created, you can set it then right?
M
Magus1,015d ago
Im building an application wich stores some information in journals (the easiest way I found to store things in the DB)... creating my own entities seemed to much trouble, but can also be used in a default state without any journal being selected. I thought it would be much easier to create a temporary journal in case no journal is selected instead of adding complexity to the logic behind it
C
Calego1,015d ago
Ahhh. I'm honestly not too familiar with how one manipulates temporary documents, I know it's possible and has uses but they're probably different methods than for ones that exist in the db.
M
Magus1,015d ago
I see, ty im going to make some research on this, probably there is a way, if I find out I tell you xd