Skip to content

Check Item Does Not Exist? #73

@cmarx-cnnect

Description

@cmarx-cnnect

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions