thunderbase

1.0.4 • Public • Published

Thunderbase

Thunderbase is real time database that is very simple to use. You don't need to use any queries. Treat your database as object. Get any data just by specifying path to it. Follow functions specified further. Establish your database in thunderbase.netlify.com and you are ready to go.

Installing

npm install thunderbase --save

Usage

import * as thunderbase from "thunderbase";

or

thunderbase = require("thunderbase");

Connect to your database If you haven't created one, you can do it here: thunderbase.netlify.com

Use your databaseId and apiKey to initialize thunderbase.

var config = {
  databaseId: xxxxx_xxxxx_xxxxx_xxxx,
  apiKey: xxxx_xxxx_xxxx_xxxx
};

Thunderbase.initialize(config);

Reading and Writing data

To read data on changes use on():

thunderbase.on(path, data => {
  console.log(data);
});

thunderbase.on(path, function(data) {
  console.log(data);
});

To stop reading data on changes use off():

thunderbase.off(path);

To read data from database use methods getFromDatabase() and once():

alt text

getFromDatabase() and once() returns Promise - you have to handle data in .then scope.

handle data with arrow function or simple function

var path = "tablesIds/AAA/smallBlind";
thunderbase.getFromDatabase(path).then(data => {
  console.log(data);
  data = data + 10;
  console.log(data);
});

thunderbase.getFromDatabase(path).then(function(data) {
  console.log(data);
});

// output: 200
// output: 210
// output: 200

synonym of getFromDatabase() is once():

thunderbase.once(path, data => {
  console.log(data);
});

thunderbase.once(path, function(data) {
  console.log(data);
});

//output: 200
//output: 200

Writing data

To write data use update()

you can update database by path like this:

updates = {};
updates["poker/" + Date.now() + "/message"] = "Does it work???";
thunderbase.update(updates).then(res => {
  console.log("here you receive response when your database is updated");
});

you will succeed in this way too:

updates = {
  poker: {
    hand: {
      name: "Full house",
      range: 3
    }
  }
};

thunderbase.update(updates);

Readme

Keywords

Package Sidebar

Install

npm i thunderbase

Weekly Downloads

5

Version

1.0.4

License

MIT

Unpacked Size

5.4 kB

Total Files

3

Last publish

Collaborators

  • rromikas