Migrating to DataModels - how to get data pre `cleanData`?

Hello. In the lancer system, we have some old fields in our Actor/Item models what predate the existence of UUIDs - they instead used a "RegRef" structure to achieve basically the same thing as a UUID now does. For context, a regref example:
{
id: "B1stOACZSDZAJLA7",
fallback_lid: "dep_ms_pattern_a_smoke_charges_smoke_mine",
type: "deployable",
reg_name: "game"
}
{
id: "B1stOACZSDZAJLA7",
fallback_lid: "dep_ms_pattern_a_smoke_charges_smoke_mine",
type: "deployable",
reg_name: "game"
}
Going forward, we'd prefer these just be a UUID string represented via a slightly modified StringField. The issue we are running into, though, is that it is difficult to migrate this data considering that the _source data of all actors is being modified via the DataModel._initializeSource -> BaseActor._initializeSource -> DataModel.cleanData, which destroys the above object and replaces it with "[object Object]". I tried accessing them via game.actors._source but it appears that the transformations in cleanData affect that data too. Is there a good way around this? Thanks
6 Replies
Mana
Mana2y ago
actor._source should not have cleanData applied unless it has been committed. If it does, then it's a bug in Foundry and should be reported. I don't know about game.actors._source tho, I'm speaking of specific actor data
Eranziel
Eranziel2y ago
You could check actor._source vs that Actor's entry in the db to confirm. If it's [object Object] then it's been committed already.
WHITESPINE
WHITESPINEOP2y ago
Hasn't been comitted because I can observe it happening across refreshes Let me get the full stack
WHITESPINE
WHITESPINEOP2y ago
DataModel constructor:
No description
WHITESPINE
WHITESPINEOP2y ago
BaseActor initializeSource:
No description
WHITESPINE
WHITESPINEOP2y ago
Using game.actors._source and a specific actor ._source both appear to have the same transformations applied I guess I'll file it since I've not been able to find any means of accessing the uncleaned data. If only I had tested before the v11 release slugboom Further investigation found game.data["actors"] which provides what I need Doesn't help with the case of compendium documents though... hm.
Want results from more Discord servers?
Add your server