firstfire
v1.0.2
Published
Firebase_database
Downloads
1
Maintainers
Keywords
Readme
Firebase Realtime Database
Introduction
Now we can do "curd" opertaion vary easy
React.js
(step1
) Firstly open terminal in Your code editor
then paste 'npm i Firebase-database'
npm i Firebase-database
(step2
) after install package create one object for (firebaseConfig
)
const firebaseConfig = {
apiKey: <`apiKey`>,
authDomain: <`authDomain`>,
databaseURL: <`databaseURL`>,
projectId: <`projectId`>,
storageBucket: <`storageBucket`>,
messagingSenderId: <`messagingSenderId`>,
appId: <`appId`>
};
(step3
) after create firebaseConfig object RUN (Firebase
) function
let Fire=Firebase(firebaseConfig)
Insert
(part-1
): After follow upper code then code write it :(this code for random keys
)
--random keys means =your data will be save with random firebase keys
let Fire=Firebase(firebaseConfig)
Fire.child(<`Enter keys:string`>).push(<`Your_data`>,function(err){
if(err)console.log("error")
else console.log("save")
})
after this code you will see "data" in your firebase realtime database penal.
(part-2
) this code for own keys:
let Fire=Firebase(firebaseConfig)
Fire.child(<`Enter keys:string`>).child(<`own-Keys`>).set(<`Your_data`>,function(err){
if(err)console.log("error")
else console.log("save")
})
show
this code for Fetch data from firebase realtime database
let Fire=Firebase(firebaseConfig)
Fire.child(<`Enter keys:string`>).on("value",function(snapshot){
let fire_Data=snapshot.val()
console.log(fire_Data)
})
Update/edit
this code for Update/edit data in firebase realtime database
let Fire=Firebase(firebaseConfig)
Fire.child(<`Enter keys:string`>).child(<`Enter data_keys`>).update(<`enter updateed value`>,function(errors){
if(errors)console.log(errors)
else console.log("update")
})
Delete
this code for Delete data in firebase realtime database
let Fire=Firebase(firebaseConfig)
Fire.child(<`Enter keys:string`>).child(<`Enter data_keys`>).remove(function(errors){
if(errors)console.log(errors)
else console.log("Delete")
})