【问题标题】:Firebase cannot update valueFirebase 无法更新值
【发布时间】:2019-09-10 14:10:51
【问题描述】:

在 Firebase 中创建/更新用户数据时出现以下错误。

服务:

createUser(user: User) {
    firebase.push(Path.DB_PATH.user, user).then((pushResult) => {
        user.key = pushResult.key;
        firebase.update(`${Path.DB_PATH.user}/${pushResult.key}`, user);
    });
}

package.json,以及所有其他文件/代码 sn-p,我分别为 Android 和 iOS 添加了google-service.jsonGoogleService-Info.plist

日志:

Native Stack:
1   0x108a5084f sig_handler(int)
2   0x10df48b5d _sigtramp
3   0x1089747a8
4   0x10de8eb4d libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_x86_64>::step()
5   0x10de92e4c _Unwind_RaiseException
6   0x10da6b4aa __cxa_throw
7   0x10cbd1bfa _objc_exception_destructor(void*)
8   0x106f82464 +[FSnapshotUtilities internalNodeFrom:priority:withValidationFrom:atDepth:path:]
9   0x106f81067 +[FSnapshotUtilities nodeFrom:priority:withValidationFrom:atDepth:path:]
10  0x106f80f08 +[FSnapshotUtilities nodeFrom:priority:withValidationFrom:]
11  0x106f80dcf +[FSnapshotUtilities nodeFrom:withValidationFrom:]
12  0x106f827a4 +[FSnapshotUtilities compoundWriteFromDictionary:withValidationFrom:]
13  0x106f398a2 -[FIRDatabaseReference updateChildValuesInternal:withCompletionBlock:from:]
14  0x106f39767 -[FIRDatabaseReference updateChildValues:withCompletionBlock:]
15  0x1093e563d ffi_call_unix64
16  0x131acd410
JS Stack:
1   updateChildValuesWithCompletionBlock@[native code]
2   @file:///node_modules/nativescript-plugin-firebase/firebase.js:1201:0
3   ZoneAwarePromise@file:///node_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:902:0
4   update@file:///node_modules/nativescript-plugin-firebase/firebase.js:1198:0
5   @file:///src/app/services/user.service.ts:37:31
6   onInvoke@file:///node_modules/@angular/core/fesm5/core.js:24349:0
7   run@file:///node_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:138:0
8   @file:///node_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:883:0
9   onInvokeTask@file:///node_modules/@angular/core/fesm5/core.js:24340:0
10  runTask@file:///node_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:188:0
11  drainMicroTaskQueue@file:///node_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:595:0
12  promiseReactionJob@:1:11
13  UIApplicationMain@[native code]
14  _start@file:///node_modules/tns-core-modules/application/application.js:277:0
15  run@file:///node_modules/tns-core-modules/application/application.js:305:0
16  bootstrapNativeScriptApp@file:///node_modules/nativescript-angular/platform-common.js:205:0
17  bootstrapApp@file:///node_modules/nativescript-angular/platform-common.js:106:0
18  bootstrapModule@file:///node_modules/nativescript-angular/platform-common.js:90:0
19  @file:///app/bundle.js:1035:144
20  ./main.ts@file:///app/bundle.js:1040:34
21  __webpack_require__@file:///src/webpack/bootstrap:750:0
22  checkDeferredModules@file:///src/webpack/bootstrap:43:0
23  <…>

```

**Package.json:**

``` JSON
 "nativescript": {
    "id": "org.nativescript.uniquiz",
    "tns-ios": {
      "version": "6.0.1"
    },
    "tns-android": {
      "version": "6.0.1"
    }
  },
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "repository": "<fill-your-repository-here>",
  "dependencies": {
    "@angular/animations": "~8.0.0",
    "@angular/common": "~8.0.0",
    "@angular/compiler": "~8.0.0",
    "@angular/core": "~8.0.0",
    "@angular/forms": "~8.0.0",
    "@angular/http": "~8.0.0-beta.10",
    "@angular/platform-browser": "~8.0.0",
    "@angular/platform-browser-dynamic": "~8.0.0",
    "@angular/router": "~8.0.0",
    "@nstudio/nativescript-cardview": "^1.0.0",
    "nativescript": "^6.0.3",
    "nativescript-angular": "~8.0.0",
    "nativescript-datetimepicker": "^1.2.1",
    "nativescript-ng-shadow": "^2.1.0",
    "nativescript-plugin-firebase": "latest",
    "nativescript-snackbar": "latest",
    "nativescript-theme-core": "~1.0.6",
    "npm": "^6.10.3",
    "reflect-metadata": "~0.1.12",
    "rxjs": "~6.5.0",
    "tns-core-modules": "^6.0.6",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~8.0.0",
    "@ngtools/webpack": "~8.0.0",
    "nativescript-dev-webpack": "^1.0.3",
    "typescript": "3.4.5"
  },package.json

【问题讨论】:

    标签: firebase firebase-realtime-database angular2-nativescript


    【解决方案1】:

    当您更新的数据的键为空时,会发生这种情况,

    ${Path.DB_PATH.user}/${pushResult.key} 这一定是空的。

    【讨论】:

      猜你喜欢
      • 2020-05-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-12
      • 2018-06-16
      • 2018-02-14
      • 1970-01-01
      相关资源
      最近更新 更多