firebase-nodejs

1.0.1-1.1 • Public • Published

firebase-nodejs Build Status Build Status Build Status

Fixed bugs 8/2/2017

  • Add callback to the some function
  • Remove default path

List function update, have a callback function

  • selectData
  • authFacebook
  • authUser updateUser updateEmail sendVerifyEmail changePassword deleteUser logout

Example new version updated.

Before updated : Have a error from return Promise, now edit.

firebaseDom.default.selectData(firebase, data_path, 'value');

New version : Remove default path. Before :

firebaseDom.default.firebaseConfig

Now :

firebaseDom.firebaseConfig

New version : Add callback function for return value from firebase query. But can't return out the function, you can use state from push on state.

firebaseDom.selectData(firebase, data_path, 'value', callback => {
   this.setState({
      callback: callback,
   });
});

Firebase SDK for Node.js

Get install !!

npm install --save firebase-nodejs firebase

Optionals

  • selectData For select data from firebase
  • insertData For insert data into firebase
  • deleteData For delete data on firebase
  • updateData For update data on firebase
  • authUser For manage user on firebase
  • authFacebook For auth from facebook

New update 5/3/2017

  • searchData => searchByValue You can use for search data by value

How to use it ?

Create firebase.js on you app folder, and write code below. You can use data from your firebase project.

import * as firebaseDom from 'firebase-nodejs';
 
var config = {
    apiKey: '',
    authDomain: '',
    databaseURL: '',
    storageBucket: '',
};
const firebase = firebaseDom.firebaseConfig(config);
export default firebase;

So you add my code on you another file for use firebase.

Examples

import firebase from './firebase'; //add you firebase.js path
import * as firebaseDom from 'firebase-nodejs';
 
export class TestApp extends Component{
  constructor(props) {
    super(props);
    this.state = {
      member: {},
    };
  }
  
  getMemberData(){
    let memberData = firebaseDom.selectData(firebase, '/member/id/1', 'value', callback => {
        this.setState({
           member: callback,
        });
    });
  }
  
  render(){
     return(
       .
       .
       .
     )
   }
}
 

Use another

authUser an authFacebook

You can authen user from firebase, Use facebook loggin only.

Get current user.

const data = firebaseDom.authUser.currentUser(firebase);

Logon by use facebook access token.

firebaseDom.authFacebook(firebase, accessToken , callback => {
    console.log(callback);
});

User data.

let currentUserData = firebaseDom.authUser.currentUser(firebase);
currentUserData.name = 'new my name';
firebaseDom.authUser.updateUser(firebase, currentUserData, callback => {
    console.log(callback);
});

User email.

firebaseDom.authUser.updateEmail(firebase, 'new_email@mail.com', callback => {
    console.log(callback);
});

User delete.

firebaseDom.authUser.deleteUser(firebase, callback => {
    console.log(callback);
});

Logout !

firebaseDom.authUser.logout(firebase, callback => {
    console.log(callback);
});

searchData

Search by value

const searchKey = 'member_name';
const searchValue = 'handdleName';
firebaseDom.searchData.searchByValue(firebase, '/member/id/', searchKey, searchValue, callback => {
    console.log(callback);
})
 

selectData

firebaseDom.selectData(firebase, '/member/id/1', 'value', callback => {
    console.log(callback);
});
 

insertData

const member = {
  name: 'test',
  age: 17,
}
const insertStatus = firebaseDom.insertData(firebase, '/member/id/2', member);
 

updateData

const member = {
  name: 'test',
  age: 18,
}
const updateStatus = firebaseDom.updateData(firebase, '/member/id/2', member);
 

deleteData

const deleteStatus = firebaseDom.deleteData(firebase, '/member/id/2');
 

Package Sidebar

Install

npm i firebase-nodejs

Weekly Downloads

2

Version

1.0.1-1.1

License

ISC

Last publish

Collaborators

  • thinnakrit