Firebase不能更新值

问题描述 投票:0回答:1

当我在Firebase中创建更新用户数据时,得到以下错误信息。

我在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和所有其他的文件代码片段都包含在其中,并且我添加了 google-service.jsonGoogleService-Info.plist 分别为Android和iOS。

日志。

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个回答
0
投票

当你更新的数据的key为空时,就会出现这种情况。

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

© www.soinside.com 2019 - 2024. All rights reserved.