Tips for removing data from documents that include automatically generated IDs

In my Angular project, I am utilizing google-cloud-firestore as the database. To import Firestore, I used the code

import { AngularFirestore } from '@angular/fire/firestore';
. The following function is used to add data to the database:

changeLevelToSelect() {

  var student = {
    id: 1001,
    name: 'Tom',
    age: 22
  };

  this.firestore.collection('School').add(student);
}

This function has been successfully implemented, and you can see the result https://i.sstatic.net/QBs7K.png.

In this particular case, I did not use the set() method with a document name; rather, I utilized the add() function. As a result, there are unique IDs assigned by Firestore instead of document names. Now I am facing an issue - how do I delete or modify this data without a specific document name for reference? Your assistance would be greatly appreciated.

Answer №1

In order to delete or edit a document, you must use its unique ID. Without the ID, you will need to formulate a query that provides access to documents for editing based on their IDs.

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

Using a configuration file with the JavaScriptServices React-Redux template

I have come across this question many times on different platforms, but I haven't been able to make it work for me. The issue is that I am using an API within a React component (with TypeScript 2.4.1 and webpack 2.5.1): .... fetch("some/url/api/", me ...

Encountering error "An import path cannot end with a '.ts' extension." when importing TypeScript file in Vue Single File Component (SFC) within VS Code

Currently, I am in the process of transitioning my .vue components from using JavaScript to TypeScript. As a result, my single file components are structured as follows: <template> ...something... </template> <script lang="ts"> import ...

What is the process for adding custom text to create a .d.ts file using the TypeScript compiler?

In my endeavor to develop a javascript module using TypeScript that is compatible with ES5 browsers and NodeJs modules, I have encountered a dilemma. I wish to avoid using import and export in TypeScrtipt as it creates dependencies on SystemJS, RequireJS, ...

Creating a modal dialog using a function in a TypeScript file

Hey there, fellow developers! I have a question that might seem simple. So, in my HTML code I've got a Modal Dialog that pops up using ng2 Bootstrap. It's working fine, but... I want to replace this line of code "<button class="btn btn-prim ...

Text input builder design pattern akin to roster creator design pattern

I have a need to create a custom free form text box builder that functions similarly to the listbuilder demonstrated in the attached image. The goal is for users to be able to input values into the textbox on the front-end HTML, click an Add button, and h ...

The 'push' property is not found within the 'Control' type

I am attempting to create an array that contains arrays within it. This array is intended for a dynamic form functionality, where the user can add a new section and push the array of control fields to the main array. Angular2 then generates this dynamical ...

Creating an eye-catching animation in Angular 2+ by applying a checkbox check effect to each checkbox dynamically generated within a loop

When I integrated a CSS animation for checkbox "cards" into an Angular project, the transition ceased to function properly. I have limited experience with Angular and am trying to work with existing code. While I managed to get a basic animation working wi ...

What purpose does the # symbol serve in Angular when interpolating values?

Here is an example provided from the following link: https://angular.io/guide/lifecycle-hooks export class PeekABoo implements OnInit { constructor(private logger: LoggerService) { } // Implementing OnInit's `ngOnInit` method ngOnInit() { this ...

Determine the outcome of the subscription using an if/else statement

I'm working on a function that needs to return a boolean value based on the result of an http post request. Here's what I have so far: checkPost(callRequest: boolean): boolean { console.log('START REQUEST'); if(call ...

Looking to reallocate information, paginate, and sort each time a new row is added to the mat-table

In my application, I have a customized <mat-table> with an implemented addRow() function that adds a new row to the table using default values based on the data type. The challenge I'm facing is that each time a new row is added, I find myself ...

What is the best way to link the value of a mat-slider to an input field in a reactive form?

Is there a way to synchronize the min and max values of a ranged mat-slider with corresponding input fields? Currently, when I set numbers in the input fields, the slider updates correctly. However, when I use the slider to change the value of the input fi ...

The id attribute is missing in ionic 2's innerHTML

I've got a script that looks like this... This is the TypeScript part: export class sampleClass { content: any; constructor(public navCtrl: NavController, public navParams: NavParams) { this.content = [ {title: "Title 1", body:"<div id ...

Instructions for transferring an object containing data from a subscribed subscription

In the UserDataService service, there is a getUser function where I fetch a token by calling the tokens function and pass it to another getUser function to retrieve a user by their id. getUser(id: number) { return this.sharedDataService.tokens.subscribe( ...

Can you explain the distinction between employing 'from' and 'of' in switchMap?

Here is my TypeScript code utilizing RxJS: function getParam(val:any):Observable<any> { return from(val).pipe(delay(1000)) } of(1,2,3,4).pipe( switchMap(val => getParam(val)) ).subscribe(val => console.log(val)); ...

Angular application integration with three.js OrthographicTrackballControls

Has anyone successfully integrated the OrthographicTrackballControls from three.js with Angular 4? I attempted to do so by running: npm install --save three-orthographic-trackball-controls Then in my component: import { OrthographicTrackballControls } f ...

angular 2 updating material table

Issue at Hand: I am facing a problem with the interaction between a dropdown menu and a table on my website. Imagine the dropdown menu contains a list of cities, and below it is a table displaying information about those cities. I want to ensure that whe ...

Reactive forms in Angular do not refresh or update automatically when a new error is added

Upon initializing my FormGroup in the ngOnInit() method, I invoke a validator function to ensure that the password and confirmPassword fields match. This is how it looks in TypeScript: regForm: FormGroup; constructor() { } ngOnInit() { this.regFo ...

Backend not receiving POST requests

I'm facing an issue where the email value I'm trying to pass to the backend is not reaching the endpoint. Despite calling the same URL path, the line console.log("You've made it to the backend"); does not output anything. What could be causi ...

Include an arrow in a personalized horizontal scroll bar using Angular and HTML

After styling a horizontal scrollbar for my chartjs graph, I attempted to add arrows using material icons like <mat-icon>keyboard_arrow_left</mat-icon>. However, I am struggling to align them next to the left and right of the scrollbar. Can any ...

Combinations of Typescript dependent unions

I'm struggling with calling the given union that wraps a function and its argument. Is there a way to call it without having to cast? type Wrapper = { fn: (a: string) => void arg: string } | { fn: (a: number) => void arg: number } let f ...