Check Item Does Not Exist?
cmarx-cnnect opened this issue · comments
Hi there. I am stuck on how to check that an item does not exist. I would do the following using vanilla IndexDB like so:
const user_exists = db.transaction('user_data').objectStore('user_data').get(user.id);
user_exists.onsuccess = ()=> {
if (!user_exists.result) {
// Do the thing
}
}
How would I do so using LocalBase? I have tried the following but the error is never caught:
db.collection('user_data').doc({ id: user.id }).get().then(document => {
console.log(document)
}).catch(error => {
// Could do the thing here if this worked
})
Thank you!