sending multiple data rows to firebase on clicking one button

Sophie Bernard

Guys <3 This is my first project with firebase and I wanna send a quite bunch of data to the database, the problem is when I click the button only the last line of code get send, I also tried to but every row in a function and call them one by one, and the same happens, only the last function work and send it's data, here's the button on click code

    @IBAction func Send(_ sender: Any) {
    apperfun();
    dnamefun();
    docfun();
    servfun();
    pnamefun();
    pnumfun();
}

and here's the functions

func apperfun() {
    if ap == "1" {self.ref.child("fullinfo").child(pname).setValue(["apperance": "Excellent"])}
    else if ap == "2" {self.ref.child("fullinfo").child(pname).setValue(["apperance": "Good"])}
    else if ap == "3" {self.ref.child("fullinfo").child(pname).setValue(["apperance": "Bad"])}
}

func dnamefun() {
    self.ref.child("fullinfo").child(pname).setValue(["dname":dname])
}

func docfun() {
    if doc == "1" {self.ref.child("fullinfo").child(pname).setValue(["level": "Excellent"])}
    else if doc == "2" {self.ref.child("fullinfo").child(pname).setValue(["level": "Good"])}
    else if doc == "3" {self.ref.child("fullinfo").child(pname).setValue(["level": "Bad"])
        self.ref.child("bad").child(pname+phone).setValue(["level": "Bad"])}
}

func servfun() {
    if serv == "1" {self.ref.child("fullinfo").child(pname).setValue(["performance": "Excellent"])}
    else if serv == "2" {self.ref.child("fullinfo").child(pname).setValue(["performance": "Good"])}
    else if serv == "3" {self.ref.child("fullinfo").child(pname).setValue(["performance": "Bad"])}
}

func pnamefun() {
    self.ref.child("fullinfo").child(pname).setValue(["pname":pname]);
}

func pnumfun() {
    self.ref.child("fullinfo").child(pname).setValue(["pnum":phone]);
}
    func receptionfun() {
        if recep == "1" {self.ref.child("fullinfo").child(pname).setValue(["reception": "Excellent"])}
        else if recep == "2" {self.ref.child("fullinfo").child(pname).setValue(["reception": "Good"])}
        else if recep == "3" {self.ref.child("fullinfo").child(pname).setValue(["reception": "Bad"])}
    }
J. Doe

setValue will replace any data in that node to your data you are setting. You want to use an update. An update will replace the key if it exists, or add it to your database if it not exists.

You have this:

if ap == "1" {self.ref.child("fullinfo").child(pname).setValue(["apperance": "Excellent"])}

It should be:

if ap == "1" {self.ref.child("fullinfo").child(pname).updateChildValues(["apperance": "Excellent"])}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

add Multiple rows in grid by clicking on button in asp.net

Sending multiple data in one page Jquery

Merge data on multiple rows in one

Hide all div and show one div on clicking multiple button

How to send extra Data and have it one after another by clicking a button

Sending Data From One Workbook to Another with Command Button

Combining data from multiple rows into one

Excel Data Manipulation - One Row into Multiple Rows

Sort data from multiple rows into one row

Rearrange data from one column into multiple rows

Select Data from multiple rows to one row

Transpose multiple rows of column of data into one column

Form in not sending the button data

Sending data from one goroutine to multiple other goroutines

Sending unnecessary data in one query response or making multiple queries?

MYSQL- Update multiple rows with one submit button

Clicking one button then activate another button

Change visibility of one button by clicking another button

Retrieve data when clicking a button

Combining multiple rows into one row with multiple columns of data R

sending multiple data ajax

Sending multiple data with AJAX

How to hide the rows in the table by clicking on button toggle

Aggregate data from multiple rows to one and then nest the data

Sending data from multiple rows to multiple textboxes in c# asp.net webform

Filtering ListView by clicking button from Firebase Database

Android- On clicking button the message sending does not stop

Sending notification Firebase with "data" and "notification"

Displaying one List at a time on Clicking button