admin管理员组

文章数量:1289483

I have a firebase database having a child - "hello" having value - "one". Now, using the javascript, I need to set the value of "hello" as "two". Thanks in advance. Please help.

I have a firebase database having a child - "hello" having value - "one". Now, using the javascript, I need to set the value of "hello" as "two". Thanks in advance. Please help.

Share Improve this question edited Jan 14, 2017 at 17:14 Frank van Puffelen 600k85 gold badges889 silver badges859 bronze badges asked Jan 14, 2017 at 16:51 Hello WorldHello World 1131 gold badge3 silver badges6 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

This is a really basic question. The answer can be easily found in the firebase docs. I'd strongly remend you to always keep an eye on the docs when learning how to use firebase, because it is a great source and it covers a lot of use cases.

First, initialize your app

var config = {
      apiKey: '<your-api-key>',
      authDomain: '<your-auth-domain>',
      databaseURL: '<your-database-url>',
      storageBucket: '<your-storage-bucket>'
};
firebase.initializeApp(config);

Then, in your javascript, make sure you have a valid reference to your database and then run either one of these lines

firebase.database().ref("hello").set('two');

or

firebase.database().ref().update({hello: 'two'});

本文标签: javascriptSet value of a child in FirebaseStack Overflow