Firebase无法更新值
我在Firebase中创建/更新用户数据时遇到以下错误 服务:Firebase无法更新值,firebase,firebase-realtime-database,angular2-nativescript,Firebase,Firebase Realtime Database,Angular2 Nativescript,我在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); }); } Nativ
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);
});
}
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
package.json
和所有其他文件/代码片段都包含在内,我分别为Android和iOS添加了google service.json
和GoogleService Info.plist
日志:
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);
});
}
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
本机堆栈:
1 0x108a5084f信号处理器(内部)
2 0x10df48b5d _sigtramp
3 0x1089747a8
4 0x10de8eb4d libunwind::UnwindCursor::step()
5 0x10de92e4c展开提升异常
6 0x10da6b4aa掷程
7 0x10cbd1bfa _objc _异常_析构函数(void*)
8 0x106f82464+[FSnapshotUtilities internalNodeFrom:priority:withValidationFrom:atDepth:path:]
9 0x106f81067+[FSnapshotUtilities节点from:priority:withValidationFrom:atDepth:path:]
10 0x106f80f08+[FSnapshotUtilities nodeFrom:priority:withValidationFrom:]
11 0x106f80dcf+[FSnapshotUtilities nodeFrom:withValidationFrom:]
12 0x106f827a4+[FSnapshotUtilities compoundWriteFromDictionary:with ValidationFrom:]
13 0x106f398a2-[FIRDatabaseReference updateChildValuesInternal:withCompletionBlock:from:]
14 0x106f39767-[FIRDatabaseReference UpdateChildValue:withCompletionBlock:]
15 0x1093e563d外国金融机构呼叫unix64
16 0x131acd410
JS堆栈:
1 updateChildValuesWithCompletionBlock@[本机代码]
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插件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
9onInvokeTask@file:///node_modules/@angular/core/fesm5/core.js:24340:0
10runTask@file:///node_modules/nativescript angular/zone js/dist/zone nativescript.js:188:0
11drainMicroTaskQueue@file:///node_modules/nativescript angular/zone js/dist/zone nativescript.js:595:0
12 PromiserreactionJob@:1:11
13 UIApplicationMain@[本机代码]
14 _start@file:///node_modules/tns core modules/application/application.js:277:0
15run@file:///node_modules/tns core modules/application/application.js:305:0
16bootstrapNativeScriptApp@file:///node_modules/nativescript angular/platform common.js:205:0
17bootstrapApp@file:///node_modules/nativescript angular/platform common.js:106:0
18bootstrapModule@file:///node_modules/nativescript angular/platform common.js:90:0
19 @file:///app/bundle.js:1035:144
20./主要问题。ts@file:///app/bundle.js:1040:34
21.需要什么样的网页__@file:///src/webpack/bootstrap:750:0
22checkDeferredModules@file:///src/webpack/bootstrap:43:0
23
```
**Package.json:**
```JSON
“nativescript”:{
“id”:“org.nativescript.uniquick”,
“tns ios”:{
“版本”:“6.0.1”
},
“tns安卓”:{
“版本”:“6.0.1”
}
},
“说明”:“NativeScript应用程序”,
“许可证”:“请参阅中的许可证”,
“存储库”:“,
“依赖项”:{
“@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浏览器”:“~8.0.0”,
“@angular/platform browser dynamic”:“~8.0.0”,
“@angular/router”:“~8.0.0”,
“@nstudio/nativescript cardwiew”:“^1.0.0”,
“nativescript”:“^6.0.3”,
“nativescript angular”:“~8.0.0”,
“nativescript日期时间选择器”:“^1.2.1”,
“nativescript ng shadow”:“^2.1.0”,
“nativescript插件firebase”:“最新”,
“nativescript snackbar”:“最新”,
“nativescript主题核心”:“~1.0.6”,
“npm”:“^6.10.3”,
“反映元数据”:“~0.1.12”,
“rxjs”:“~6.5.0”,
“tns核心模块”:“^6.0.6”,
“zone.js”:“~0.9.1”
},
“依赖性”:{
“@angular/compiler cli”:“~8.0.0”,
“@ngtools/webpack”:“~8.0.0”,
“nativescript开发人员网页包”:“^1.0.3”,
“类型脚本”:“3.4.5”
},package.json
当您更新的数据键为空时,会发生这种情况
${Path.DB_Path.user}/${pushResult.key}
这一定是空的