Open NFTYieldFarm opened 1 year ago
I can't reproduce this, with this code. It seems to properly call addKey when the entry for the key doesn't exist and doesn't call it when it does exist. Are you using the latest version? Do you have a more complete/reproducible case?
If I run this exact code outside of a transaction it behaves properly, if I write it inside of a transaction, it behaves abnormally.
function addKey(key: string, name: string) { db.get(key) // { test } db.put(key, { name }); db.get(key) // { test2 } }
db.transaction(async () => { const exists = await db.ifNoExists(key, () => addKey(key, "test2")); // regardless if exists resolves to true or false, it is still changing name from test to test2. }