使用错误更新Firebase多位置:Path是Path的祖先。迅速

时间:2017-12-13 15:48:58

标签: swift firebase firebase-realtime-database

当我尝试使用
在多个位置更新数据库时   .updateChildValues,我收到下面列出的错误。我该如何解决这个问题?

  

由于未捕获的异常终止应用' InvalidFirebaseData',   原因:'(updateChildValues :)对象中的路径无效。路径   (/ Payments / osGRNIZzbRWtllehAXbGJ5NtmRe2 / 1513178895/730890027)是一个   的祖先   (/付款/ osGRNIZzbRWtllehAXbGJ5NtmRe2 /730890027分之1513178895/预订)'

      let timeStamp = String(Int(Date().timeIntervalSince1970))
        let paymentRef = self.random9DigitString()

        var finalBookingArray = [String: AnyObject]()
        for booking in self.bookingsFromQuery {

            let bookingForPayPeriod = DisbursePaymentData(

                numberOfHours: booking.NumberOfHours,
                bookingAmount: booking.BookingAmount,
                amountPaidToCleanerForBooking: booking.AmountPaidToCleanerForBooking ?? "",
                checkInDate: booking.checkInDate ?? "",
                checkOutDate: booking.checkOutDate ?? "",
                checkInTimeStamp: booking.checkInTimeStamp ?? "",
                checkOutTimeStamp: booking.checkOutTimeStamp ?? "",
                ratePriceClient: booking.RatePriceClient ?? "",
                rateNumberClient: booking.RateNumberClient ?? "",
                ratePriceCleaner: booking.RatePriceCleaner ?? "",
                rateNumberCleaner: booking.RateNumberCleaner ?? "",
                cancelledBy: booking.objectsUnderCancelledBy)

              let bookingCompleted = bookingForPayPeriod.convertDisbursePaymentDataToAnyObject()
                finalBookingArray[booking.BookingNumber] = bookingCompleted
        }

        let finalObject = DisbursePaymentData(
            payPeriodDateStartDate: self.fromDateString.text!,
            payPeriodEndDate: self.toDateString.text!,
            payPeriodTimeStampStartDate: String(describing: self.startDateTimeStamp),
            payPeriodTimeStampEndDate: String(describing: self.endDateTimeStamp),
            paymentRef: paymentRef)

      let objectComplete = finalObject.toAnyObj()
          let childUpdates = ["Payments/\(uid)/\(timeStamp)/\(paymentRef)" : objectComplete,
                              "Payments/\(uid)/\(timeStamp)/\(paymentRef)/\("bookings")" : finalBookingArray
        ] as [String : Any] 

    self.dbRef.updateChildValues(childUpdates)

架构:

Payments  
 -timeStamp
   -paymentRef


       payPeriodDateStartDate: date1
       payPeriodEndDate: - date 2
       payPeriodTimeStampStartDate: tstamp1
       payPeriodTimeStampEndDate:   tstamp2
       paymentRef: generate9DIgits
       Total:
       allfees: 
       netPay:
       //---->>the key:value pairs above represent objectComplete that I set above

      - bookings  // -> this is finalBookingArray that I set above
           booking1
             - hours: 
             - originalPriceOfBooking
             - amountPaidToCleanerForBooking
             -ratePriceClientContent
             -rateNumberClientContent
             -ratePriceCleanerContent
             -rateNumberCleanerContent
             -checkInDate:
             -checkOutDate:                    
             -checkInTimeStamp:
             -checkOutTimeStamp:
             -cancelledBy
               -timeStamp
                   values under timeStamp
 booking2

0 个答案:

没有答案