Unable to modify data with ionic and firebase in child node format

I am encountering an issue when updating data with Ionic Firebase using the following code. Instead of rewriting the previous data, it simply creates new data entries. Here is the code snippet:

updateLaporan()
      {
        this.id =this.fire.auth.currentUser.uid;    
        this.db.object('/laporan/'+ this.id+ this.uid).set({
          porsiKarbohidrat : this.porsiKarbohidrat.value,
          porsiProteinHewani : this.porsiProteinHewani.value,
          porsiProteinNabati : this.porsiProteinNabati.value,
          porsiLemak : this.porsiLemak.value,

         })

         this.alert("Success")
      }

Here is a screenshot of my database structure: Firebase Structure This image illustrates what happens when I use that specific code: Results of Running the Code

Answer №1

To navigate further into the database, remember to include a / between your IDs.

this.db.object('/report/'+ this.id+'/'+ this.username).update()

It is recommended to use .update instead of .set to prevent overwriting everything under the current node.

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

Is there a way to continuously iterate through arrays in Firebase to make updates to object properties?

I am currently developing an inventory management application using AngularJS, Firebase, and the AngularFire library. One issue I'm facing is updating the unit number when a user performs an Import/Export action. I am unsure of how to retrieve the ...

Ensuring the Presence of a Legitimate Instance in NestJS

I have been working on validating my request with the Product entity DTO. Everything seems to be in order, except for the 'From' and 'To' fields. The validation works correctly for the Customer and Type fields, but when incorrect data i ...

Ensuring a child element fills the height of its parent container in React Material-UI

Currently, I am in the process of constructing a React Dashboard using MUI. The layout consists of an AppBar, a drawer, and a content area contained within a box (Please correct me if this approach is incorrect)... https://i.stack.imgur.com/jeJBO.png Unf ...

user interface grid element in Materia

After writing this code, I encountered the following error: No overload matches this call. Overload 1 of 2, '(props: { component: ElementType<any>; } & SystemProps<Theme> & { children?: ReactNode; classes?: Partial<GridClasses>; .. ...

Requirements for Method Decorators - The complete path of the class module using the decorator must be provided

Upon running the decorator (method decorators) function, we are provided with access to target, methodName, and descriptor. I am seeking the module path for target in this specific scenario. Essentially, I want the file path that points to the module that ...

How come only a single field is getting assigned when a new document is generated in Firebase, despite passing in multiple fields?

I’m in the process of generating a document within my "Users" collection that contains various fields (such as role, email, createdAt). I have these fields and their corresponding data stored in a "data" variable, and I’m setting the document to that o ...

What is the best way to target all select2 elements with a single button click?

Utilizing the Select2 feature of angular for multiple selection, I am in need of a function that allows me to select all elements with a single click on a button or checkbox. https://www.npmjs.com/package/ng-select2 My attempt at inserting all ele ...

Oh no, an issue has occurred with The Angular Compiler! It appears that TypeScript version 3.9.10 was found instead of the required version, which should be >=3.6.4 and <

After upgrading my angular application from version 5 to version 9, I encountered an issue while trying to deploy my code on the server. ERROR in The Angular Compiler requires TypeScript >=3.6.4 and <3.9.0 but 3.9.10 was found instead. Even though ...

Deciphering key-value pairs that are separated by commas

I am looking to convert the following format: realm="https://api.digitalocean.com/v2/registry/auth",service="registry.digitalocean.com",scope="registry:catalog:*" Into this JSON object: { realm: "https://api.digitaloce ...

Resolving NPM Error: Resolving the conflict with upstream dependencies when installing NPM Packages for Cloud Functions

After updating my firebase functions by running npm i firebase-functions@latest and also updating with npm install -g firebase-tools, I encountered an issue where I am unable to deploy all of my functions using firebase deploy --only functions. The error m ...

Can you explain how to utilize multiple spread props within a React component?

I'm currently working in TypeScript and I have a situation where I need to pass two objects as props to my React component. Through my research, I found out that I can do this by writing: <MyComponent {...obj1} {...obj2} /> However, I'm fa ...

How can you eliminate the first elements of two or more arrays of objects until all of their first elements match based on a specific field?

My Typescript code includes a Map object called `stat_map` defined as const stat_map: Map<string, IMonthlyStat[]> = new Map(); The interface IMonthlyStat is structured as shown below (Note that there are more fields in reality) export interface IMon ...

Arranging Objects in Angular 2 using Pipes

While I've come across similar questions, none of the solutions provided have worked for me so far. Therefore, please refrain from marking this as a duplicate unless you can point me to an answer that actually resolves my issue. Currently, I am worki ...

The module 'SharedModule' has imported an unexpected value of 'undefined'

When working with an Angular application, I want to be able to use the same component multiple times. The component that needs to be reused is called DynamicFormBuilderComponent, which is part of the DynamicFormModule. Since the application follows a lib ...

Issue with Angular 7 cli failing to recognize a custom TypeScript file

While working on an Angular 7 component, I encountered an issue when trying to read a custom file. The problem arises when the server restarts, even though there are no errors in the component's TypeScript file. ERROR: app/zontify-components/zonti ...

The *ngIf directive is refusing to display a template

I am currently facing an issue with my .html file where I am trying to display values based on a condition using "*ngIf". The condition is to find a value that ends with "Rechercher ...", but I am having trouble getting it to work. I have tried various app ...

What is the best way to interrupt the current song playing?

I am currently working on developing an audio player using reactjs that has a design similar to this https://i.sstatic.net/Hnw0C.png. The song boxes are rendered within a map function, and when any song box is clicked, it should start playing. However, I a ...

What is the best way to customize the styles of Material UI V5 Date Pickers?

Attempting to customize Mui X-Date-Pickers V5 through theme creation. This particular component is based on multiple layers. Interested in modifying the borderColor property, but it's currently set on the fieldset element, so need to navigate from Mu ...

Exclude file from the source directory in Webpack configuration

My Angular project is set up with webpack for compilation, but I am facing an issue with separate main files for different environments (main.dev-only.ts, ...). Whenever I try to compile, I encounter the following error: ERROR in : Type in is part of the ...

What steps can be taken to prioritize files with specific extensions in webpack?

I have a dilemma with two files: - somefile.scss - somefile.scss.ts When importing the file in my typescript code, it is referencing the wrong one: import styles from "somefile.scss" The typescript part works fine with the correct import (.scss ...