mirror of
https://gitea.tendokyu.moe/ppc/amnet.git
synced 2026-09-22 22:28:22 +03:00
prevent nested transactions
This commit is contained in:
@@ -15,20 +15,18 @@ const migrationFunction = (oldRealm: Realm, newRealm: Realm) => {
|
||||
if (card.lastUsedGameId && card.lastUsed) {
|
||||
const existing = gameIdMap.get(card.lastUsedGameId);
|
||||
if (!existing || card.lastUsed > existing.lastUsed) {
|
||||
gameIdMap.set(card.lastUsedGameId, { card, lastUsed: card.lastUsed });
|
||||
gameIdMap.set(card.lastUsedGameId, {card, lastUsed: card.lastUsed});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// write new history records
|
||||
const newCards = newRealm.objects("card");
|
||||
newRealm.write(() => {
|
||||
gameIdMap.forEach((value, gameId) => {
|
||||
const newCard = newCards.filtered(`_id == $0`, value.card._id)[0];
|
||||
newRealm.create("cardUsageHistory", {
|
||||
gameId: gameId,
|
||||
card: newCard
|
||||
});
|
||||
gameIdMap.forEach((value, gameId) => {
|
||||
const newCard = newCards.filtered(`_id == $0`, value.card._id)[0];
|
||||
newRealm.create("cardUsageHistory", {
|
||||
gameId: gameId,
|
||||
card: newCard
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user