All Projects â†’ ImangazalievM â†’ Reactiveandroid

ImangazalievM / Reactiveandroid

Licence: mit
🚀 Simple and powerful ORM for Android

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Reactiveandroid

Freezer
A simple & fluent Android ORM, how can it be easier ? RxJava2 compatible
Stars: ✭ 326 (+219.61%)
Mutual labels:  rxjava, orm, database, sqlite
Maghead
The fastest pure PHP database framework with a powerful static code generator, supports horizontal scale up, designed for PHP7
Stars: ✭ 483 (+373.53%)
Mutual labels:  orm, database, sqlite
Node Orm2
Object Relational Mapping
Stars: ✭ 3,063 (+2902.94%)
Mutual labels:  orm, database, sqlite
Denodb
MySQL, SQLite, MariaDB, PostgreSQL and MongoDB ORM for Deno
Stars: ✭ 498 (+388.24%)
Mutual labels:  orm, database, sqlite
Ebean
Ebean ORM
Stars: ✭ 1,172 (+1049.02%)
Mutual labels:  orm, database, sqlite
Mikro Orm
TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL and SQLite databases.
Stars: ✭ 3,874 (+3698.04%)
Mutual labels:  orm, database, sqlite
Android Orma
An ORM for Android with type-safety and painless smart migrations
Stars: ✭ 442 (+333.33%)
Mutual labels:  orm, database, sqlite
Prisma
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite & MongoDB (Preview)
Stars: ✭ 18,168 (+17711.76%)
Mutual labels:  orm, database, sqlite
Nano Sql
Universal database layer for the client, server & mobile devices. It's like Lego for databases.
Stars: ✭ 717 (+602.94%)
Mutual labels:  orm, database, sqlite
Typeorm
ORM for TypeScript and JavaScript (ES7, ES6, ES5). Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.
Stars: ✭ 26,559 (+25938.24%)
Mutual labels:  orm, database, sqlite
Db
Data access layer for PostgreSQL, CockroachDB, MySQL, SQLite and MongoDB with ORM-like features.
Stars: ✭ 2,832 (+2676.47%)
Mutual labels:  orm, database, sqlite
Hunt Entity
An object-relational mapping (ORM) framework for D language (Similar to JPA / Doctrine), support PostgreSQL and MySQL.
Stars: ✭ 51 (-50%)
Mutual labels:  orm, database, sqlite
Piccolo
A fast, user friendly ORM and query builder which supports asyncio.
Stars: ✭ 219 (+114.71%)
Mutual labels:  orm, database, sqlite
Wetland
A Node.js ORM, mapping-based. Works with MySQL, PostgreSQL, SQLite and more.
Stars: ✭ 261 (+155.88%)
Mutual labels:  orm, database, sqlite
Rustorm
an orm for rust
Stars: ✭ 205 (+100.98%)
Mutual labels:  orm, database, sqlite
Simple Crud
PHP library to provide magic CRUD in MySQL/Sqlite databases with zero configuration
Stars: ✭ 190 (+86.27%)
Mutual labels:  orm, database, sqlite
Linq2db
Linq to database provider.
Stars: ✭ 2,211 (+2067.65%)
Mutual labels:  orm, database, sqlite
Nut
Advanced, Powerful and easy to use ORM for Qt
Stars: ✭ 181 (+77.45%)
Mutual labels:  orm, database, sqlite
Go Sqlbuilder
A flexible and powerful SQL string builder library plus a zero-config ORM.
Stars: ✭ 539 (+428.43%)
Mutual labels:  orm, database, sqlite
Bookshelf
A simple Node.js ORM for PostgreSQL, MySQL and SQLite3 built on top of Knex.js
Stars: ✭ 6,252 (+6029.41%)
Mutual labels:  orm, database, sqlite

logo

Build Status Download minSdkVersion 14 License: MIT

Full Documentation: ReActiveAndroid

ReActiveAndroid is Android ORM based on popular library ActiveAndroid. Unfortunately, the author of the library stopped maintaining it, so I decided to continue maintain the library instead of him.

New features in ReActiveAndroid in comparison with ActiveAndroid:

  • multiple databases support
  • more convenient migration mechanism
  • a new and improved syntax for creating SQL queries
  • One-to-Many relation
  • inherited models
  • table/model change notifications
  • RxJava 2 support
  • fixed bugs and more

In the plans:

  • Annotation Processing instead of Java Reflection
  • improved compatibility with Kotlin
  • composite primary key support
  • SQL Cipher support
  • AutoValue support

Installation

Add this to your app build.gradle:

implementation 'com.reactiveandroid:reactiveandroid:1.4.3'

Initial setup

First, we need to create a database class:

@Database(name = "MyDatabase", version = 1)
public class AppDatabase {

}

In the @Database annotation we specified the name of the database without an extension and the version of the schema.

Next, we need to initialize the library in the onCreate method of the Application class:

DatabaseConfig appDatabase = new DatabaseConfig.Builder(AppDatabase.class)
        .build();

ReActiveAndroid.init(new ReActiveConfig.Builder(this)
        .addDatabaseConfigs(appDatabase)
        .build());

Creating tables

To create a table, we need to create a model class that inherits from the Model class and annotate it with @Table:

@Table(name = "Notes", database = AppDatabase.class)
public class Note extends Model {

    @PrimaryKey
    private Long id;
    @Column(name = "title")
    private String title;
    @Column(name = "text")
    private String text;

    public Note(String title, String text) {
        this.title = title;
        this.text = text;
    }

    public Long getId() {
        return id;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getTitle() {
        return title;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String getText() {
        return text;
    }

}

In the @Table annotation we specify table name and the database class in which the table belongs. Also you can create a model class without inheritance from the Model, but then you will not have access to save() and delete() methods.

Now we can save, update and delete records:

Note note = new Note("Title", "Text");
note.save();

note.setText("New text");
note.save();

note.delete();

Query building

Building a query in ReActiveAndroid is like building a normal SQL statement:

//inserting record
Insert.into(Note.class).columns("title", "text").values("Title", "Text").execute();

//getting all table records
List<Note> notes = Select.from(Note.class).fetch();

//getting a specific record
Note note = Select.from(Note.class).where("id = ?", 1).fetchSingle();

//getting a selection of records
List<Note> notes = Select.from(Note.class).where("title = ?", "title").fetch();

//updating record
Update.table(Note.class).set("title = ?", "New title").where("id = ?", 1).execute();

//deleting record
Delete.from(Note.class).where("id = ?", 1).execute();

License

The MIT License

Copyright (c) 2017-2018 Mahach Imangazaliev

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].