Skip to content

Latest commit

 

History

History
63 lines (46 loc) · 998 Bytes

README.md

File metadata and controls

63 lines (46 loc) · 998 Bytes

Description

This is a simple todo app with react and firebase realtime database.

install

npm install

crud

create

    const ref = firebase.database().ref("your ref");
    // initialize data
    const data = {....}
    //add to db
    ref.push(data);

delete entire data

const ref = firebase.database().ref('your ref');
ref.remove(data);

delete child data

const child = firebase.database().ref('parent').child(id);
child.remove();

update

    //select which child you want to update
    const child = firebase.database().ref("partent").child(id);
    child.update({
        complete:true,
        ...
    })

read

const ref = firebase.database().ref('parent');

ref.on('value', (snapshot) => {
  console.log(snapshot.val());
});

/* this will listen to the parent if there is something change */

ref.once('value', (snapshot) => {
  console.log(snapshot.val());
});
/* this will listen only one time*/