Is there a way to access or delete a randomly generated document ID in Firestore?

Need help with code to delete an item (current method not working)

const docRef = firebase.firestore().collection('users').doc(firebase.auth().currentUser.uid)
docRef.collection('tasks').doc(this.task.id).delete()

Answer №1

Make sure to properly handle the promise by using either a then or async/await, following the guidelines outlined in this documentation.

Furthermore, double-check if your code assumes tasks are nested within individual user documents. If this is not accurate, you might be referencing the wrong collection. As a first step, consider executing a

.get().then(res => console.log(res))
for both the user and their respective tasks. Remember, if you can't retrieve the document successfully, you won't be able to delete it.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The issue arises when the export function is triggered within the getStaticPaths() method, preventing the top-level

For my Next.js SSG (static site generation) app, I decided to optimize the database connection process by exporting a global promise from one file and then utilizing it in another file called controllers.js. This file houses multiple functions that directl ...

What is the best way to effectively apply a mask within a PixiJS container so that its color does not display upon page refresh?

After implementing the code snippet below to add a mask in a container, I encountered an issue where upon clicking the refresh button on the page (chrome), the pixi stage would turn completely white until the refreshing process is completed. Can anyone p ...

Utilizing Google Tag Manager for Efficiently Managing Multiple Schema Product Reviews with JSON-LD and Variables

Currently, I am facing a challenge while using Google Tag Manager to incorporate Schema JSON-LD Product reviews on certain pages. Despite my efforts, I am unable to locate any relevant resources to resolve this issue. The main problem lies in informing GT ...

The issue of event emission not being registered for custom filters in vue-tables-2

I keep encountering this issue: "TypeError: Event.$emit is not a function" every time the watcher triggers. Even though I imported the Event object in my main.js file and can log it to the console, I am using a named prop due to having three different cli ...

Authorization based on user roles in Node.js or Express.js

Are there any modules available for implementing role-based authorization in node.js or Express js? For example, having roles such as Super Admin, Admin, Editor, and User? ...

Keep track of open tabs and their content by utilizing sessions

I am working with Bootstrap Tabs where I have loaded content dynamically using jQuery's load() function. In addition, when a button is clicked, a new tab is generated automatically with a basic HTML form containing various input fields, which is then ...

Utilizing JavaScript libraries in a TypeScript project: A step-by-step guide

Currently, I am working on an existing TypeScript AngularJS project and looking to incorporate d3js. However, due to restrictions with the corporate proxy, I am unable to use tools for downloading or managing dependencies. As a result, I have opted for man ...

What is the best way to retrieve JavaScript variable data from a GDownloadUrl callback function?

Recently, I attempted to extract data by crawling a website. The website in question offers real-time information on bicycle stations through Google Maps. GDownloadUrl("/mapAction.do?process=statusMapView", function(data, responseCode) { var jso ...

What is the best way to initiate JavaScript using a button click in WordPress?

I need to add a button to a WordPress page that triggers a JavaScript function when clicked. Here is the HTML code: <!DOCTYPE html> <html lang="en"> <head> <title></title> </head> <body> < ...

Issues arising when attempting to connect Vue.js to Neo4j database

Just starting out with vue.js and neo4j, I decided to give the Vue-neo4j connector a try. Unfortunately, even after following the instructions in the read.me file, nothing happens when I click connect, and there are no errors in the console. Can anyone ass ...

Retrieve the child grid's data source in Kendo using Angular

I am currently working with a master detail grid in Kendo Grid and using the Angular version of the Kendo Grid. One interesting feature I have added is a custom button for adding a new record in each row of the grid. When this button is clicked, a new rec ...

What is the best way to programmatically route or navigate to a specific route within a Next.js class component?

tag: In the process of creating my app with next.js, I primarily use functional components. The sole exception is a class component that I utilize to manage forms. Upon form submission, my goal is to redirect back to the home page. However, when I attemp ...

What is the best way to include the ID when making edits in Angular?

Is there a way to pass the ID when a user edits a document? Below is the HTML and component.ts code: HTML <h1 mat-dialog-title>Hi {{data.name}}</h1> <form [formGroup]="addTaskForm" (ngSubmit)="save()" > <mat-form-field> <ma ...

Tips for personalizing the NavigatorIOS's right side

Looking to create a navigation bar similar to Whatsapp's? I want to include a profile picture and call button on the right side of the bar. Any tips on how to achieve this look? Which properties should be used for this customization? Would it be bet ...

Transforming an Input Field into a String with React's onChange Event

I have a small application consisting of three components Parent Component: App Son Component: Courses Grandchild Component: Course The state of the app is stored in the App component. In the Course component, there is an input field with an onChange ev ...

Vue-NativeScript image zooming feature

Currently in the development phase, I am working on a simple application that contains a list of items. When an item is selected from the list, its corresponding image should appear in an image tag. However, there seems to be an issue with the width of t ...

Conceal rows in a table that are not selected using Jquery when the table has been loaded from a given URL

Below is the HTML code for an user search input field and the results table: <div class="input-group"> <input type="text" id="q" class="form-control" placeholder="Search for User"> <span class="input-group-btn"> ...

Unable to utilize the "let" keyword in WebStorm

Currently, I am delving into learning typescript and attempting to create a simple 'let' statement. However, I encountered an error indicating the need to use ECMAScript 6 or later versions. The exact message from the typescript compiler states: ...

Keeping the Drawer open in Material-UI: What you need to know!

I am looking to create a collapsible sidebar feature in Material-UI where only the icons are displayed when collapsed. I have successfully implemented the Mini Variant Drawer for the basic sidebar functionality, but I'm facing an issue with maintainin ...

Issue with TypeScript not detecting exported Firebase Cloud Functions

Dealing With Firebase Cloud Functions Organization I am managing a large number of Firebase Cloud Functions, and in order to keep the code well-structured, I have divided them into separate files for each function category (such as userFunctions, adminFun ...