You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 8, 2026. It is now read-only.
awaitthis.databaseService.request("UPDATE inventories SET metadata = ? WHERE user_id = ? AND item_id = ? AND JSON_EXTRACT(metadata, '$._unique_id') = ?",[metadataJson,userId,itemId,uniqueId]);
75
98
}
76
-
asyncremoveItem(userId,itemId,amount){
77
-
constitems=awaitthis.databaseService.read(`SELECT * FROM inventories WHERE user_id = ? AND item_id = ? AND metadata IS NULL ORDER BY amount DESC`,[userId,itemId]);
78
-
console.log(`Removing ${amount} of item ${itemId} from user ${userId}`);
awaitthis.databaseService.request(`DELETE FROM inventories WHERE user_id = ? AND item_id = ? AND sellable = ? AND amount = ? AND purchasePrice = ? LIMIT 1`,[userId,item.item_id,item.sellable ? 1 : 0,item.amount,item.purchasePrice]);
109
+
}
110
+
else{
111
+
awaitthis.databaseService.request(`UPDATE inventories SET amount = ? WHERE user_id = ? AND item_id = ? AND metadata IS NULL AND sellable = ? AND amount = ? AND purchasePrice = ? LIMIT 1`,[newAmount,userId,item.item_id,item.sellable ? 1 : 0,item.amount,item.purchasePrice]);
112
+
}
113
+
return;
114
+
}
115
+
// Sinon, comportement classique (réparti sur tous les stacks)
awaitthis.databaseService.request(`DELETE FROM inventories WHERE user_id = ? AND item_id = ? AND metadata IS NULL AND sellable = ?`,[userId,itemId,item.sellable ? 1 : 0]);
123
+
awaitthis.databaseService.request(`DELETE FROM inventories WHERE user_id = ? AND item_id = ? AND metadata IS NULL AND sellable = ? AND amount = ? LIMIT 1`,[userId,itemId,item.sellable ? 1 : 0,item.amount]);
88
124
}
89
125
else{
90
-
awaitthis.databaseService.request(`UPDATE inventories SET amount = ? WHERE user_id = ? AND item_id = ? AND metadata IS NULL AND sellable = ?`,[newAmount,userId,itemId,item.sellable ? 1 : 0]);
126
+
awaitthis.databaseService.request(`UPDATE inventories SET amount = ? WHERE user_id = ? AND item_id = ? AND metadata IS NULL AND sellable = ? AND amount = ? LIMIT 1`,[newAmount,userId,itemId,item.sellable ? 1 : 0,item.amount]);
constitems=awaitthis.databaseService.read(`SELECT * FROM inventories WHERE user_id = ? AND item_id = ? AND metadata IS NULL AND sellable = 1 AND purchasePrice = ? ORDER BY amount DESC`,[userId,itemId,purchasePrice]);
163
+
// Si dataItemIndex est défini, on ne retire que sur ce stack précis
awaitthis.databaseService.request(`DELETE FROM inventories WHERE user_id = ? AND item_id = ? AND metadata IS NULL AND sellable = 1 AND amount = ? AND purchasePrice = ? LIMIT 1`,[userId,itemId,item.amount,purchasePrice]);
170
+
}
171
+
else{
172
+
awaitthis.databaseService.request(`UPDATE inventories SET amount = ? WHERE user_id = ? AND item_id = ? AND metadata IS NULL AND sellable = 1 AND amount = ? AND purchasePrice = ? LIMIT 1`,[newAmount,userId,itemId,item.amount,purchasePrice]);
173
+
}
174
+
return;
175
+
}
176
+
// Sinon, comportement classique (réparti sur tous les stacks)
awaitthis.databaseService.request(`DELETE FROM inventories WHERE user_id = ? AND item_id = ? AND metadata IS NULL AND sellable = 1 AND purchasePrice = ?`,[userId,itemId,purchasePrice]);
184
+
awaitthis.databaseService.request(`DELETE FROM inventories WHERE user_id = ? AND item_id = ? AND metadata IS NULL AND sellable = 1 AND amount = ? AND purchasePrice = ? LIMIT 1`,[userId,itemId,item.amount,purchasePrice]);
135
185
}
136
186
else{
137
-
awaitthis.databaseService.request(`UPDATE inventories SET amount = ? WHERE user_id = ? AND item_id = ? AND metadata IS NULL AND sellable = 1 AND purchasePrice = ?`,[newAmount,userId,itemId,purchasePrice]);
187
+
awaitthis.databaseService.request(`UPDATE inventories SET amount = ? WHERE user_id = ? AND item_id = ? AND metadata IS NULL AND sellable = 1 AND amount = ? AND purchasePrice = ? LIMIT 1`,[newAmount,userId,itemId,item.amount,purchasePrice]);
0 commit comments