Coder Social home page Coder Social logo

firebase's Introduction

FireBase (Qt)

FireBase is the mobile platform which allows to develop high-quality applications quickly. It is necessary to have the account FireBase for use of library. Version Qt 5.7.1

Facility

  Send single data
  Send data objects
  Edit data
  Delete data
  Rewrite data
  Obtain data
  Obtain the sorted data

Data access makes only in one parameter. It is technical aspect of FireBase. At the time of writing this library their answer about of a possibility of data access according to some data was the following:

Thank you for your patience. Like you, there are other developers requesting for these features. In fact, there's already an existing internal request to address this functionality. But as of the moment, no public release dates or details we can share.

Installation

Installation of library is standard installation of third-party libraries in Qt. It is necessary to download sources and to bring together library under your own system. Then following documentation of Qt you connect it to your own project.

Example of a code:

    QString http = "https://test.firebaseio.com/";
    QString token = "SECRET KEY";
    FireBase firebase(http, token);

Data record

This method will write down data with own key from FireBase.

    QString str = "Money";
    QJsonObject object;
    object["value"] = 25345685;
    object["story"] = "many";
    firebase.child(str)->value(object)->push();

This method will write down data using YOUR key.

    QString str = "MY_KEY/Money";
    QJsonObject object;
    object["value"] = 25345685;
    object["story"] = "many";
    firebase.child(str)->value(object)->set();

Data editing

    QString str = "Money";
    QJsonObject object;
    object["value"] = 25;    
    firebase.child(str)->value(object)->update();

Data deletion

    QString str = "Money";
    firebase.child(str)->remove();

Getting data

    QString str = "Money";
    QString data = firebase.child(str)->get();

Sorting

For sorting of data it is necessary to create rules on the party of FireBase.

  • orderBy - the parameter by which we sort
  • startAt - for example, from 100 and above
  • limitToFirst - for example, the first 20 sorted
  • endAt - for example to 100 and below
  • limitToLast - the last 20 sorted

Example of a code when it is necessary to receive the first 100 records on the “value” parameter a meaning of which not less than 10 000

    QString str = "Money";
    QString orderBy = "value";
    QString data = firebase.child(str)->orderBy(orderBy)->startAt(10000)->limitToFirst(100)->get();

Example of a code when it is necessary to receive the last 100 records on the “value” parameter a meaning of which less than 10 000

    QString str = "Money";
    QString orderBy = "value";
    QString data = firebase.child(str)->orderBy(orderBy)->endAt(10000)->limitToLast(100)->get();

LECENSE

See LICENSE.txt for details.

RU

Firebase представляет собой мобильную платформу, которая позволяет быстро разрабатывать высококачественные приложения. Для использования библиотеки необходимо иметь аккаунт Firebase. Версия Qt 5.7.1

Возможности

  Отправлятть единичные данные
  Отправлять объекты данных
  Редактировать данные
  Удалять данные
  Перезаписывать данные
  Получать данные
  Получать отсортированные данные

Выборка данных происходит только по одному параметру. Это техническая сторона FireBase. На момент написания данной библиотеки их ответ по вопросу о возможности выборки по нескольим данным был следующим:

Thank you for your patience. Like you, there are other developers requesting for these features. In fact, there's already an existing internal request to address this functionality. But as of the moment, no public release dates or details we can share.

Установка

Установка библиотеки является стандартной установкой сторонних библиотек в Qt. Необходимо скачать исодники и собрать библиотеку под свою систему. Далее следуя док-ции Qt подключить её к своему проекту.

Пример кода:

    QString http = "https://test.firebaseio.com/";
    QString token = "SECRET KEY";
    FireBase firebase(http, token);

Запись данных

Данный метод запишит данные с собственным ключом от FireBase.

    QString str = "Money";
    QJsonObject object;
    object["value"] = 25345685;
    object["story"] = "many";
    firebase.child(str)->value(object)->push();

Данный метод запишит данные используя ваш ключ.

    QString str = "MY_KEY/Money";
    QJsonObject object;
    object["value"] = 25345685;
    object["story"] = "many";
    firebase.child(str)->value(object)->set();

Редактирование данных

    QString str = "Money";
    QJsonObject object;
    object["value"] = 25;    
    firebase.child(str)->value(object)->update();

Удаление данных

    QString str = "Money";
    firebase.child(str)->remove();

Получение данных

    QString str = "Money";
    QString data = firebase.child(str)->get();

Сортировка

Для сортировки данных необходимо на стороне FIreBase создать правила.

  • orderBy - параметр по которому сортируем
  • startAt - например, от 100 и выше
  • limitToFirst - например, первые 20 отсортированных
  • endAt - например до 100 и ниже
  • limitToLast - последние 20 отсортированных

Пример кода когда нужно получить первые 100 записей по параметру "value" зачение которого не менее 10 000

    QString str = "Money";
    QString orderBy = "value";
    QString data = firebase.child(str)->orderBy(orderBy)->startAt(10000)->limitToFirst(100)->get();

Пример кода когда нужно получить последние 100 записей по параметру "value" зачение которого менее 10 000

    QString str = "Money";
    QString orderBy = "value";
    QString data = firebase.child(str)->orderBy(orderBy)->endAt(10000)->limitToLast(100)->get();

LECENSE

See LICENSE.txt for details.

firebase's People

Watchers

 avatar  avatar

Forkers

tvixxx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.