All Projects → cmelchior → Realmfieldnameshelper

cmelchior / Realmfieldnameshelper

Licence: apache-2.0
Realm extension library used to create more type-safe queries.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Realmfieldnameshelper

Realm Graphql
GraphQL client for Realm Object Server
Stars: ✭ 79 (-54.6%)
Mutual labels:  realm
Realm Browser
Android Database Browser for realm-java
Stars: ✭ 101 (-41.95%)
Mutual labels:  realm
Awesome Blogs Android
어썸블로그 ・ 개발 블로그 모음 ・ 개발 잡덕들을 위한 본격 고퀄리티 개발 블로그 큐레이션 서비스 🕵️‍♀️
Stars: ✭ 128 (-26.44%)
Mutual labels:  realm
Newspaper
An aggregated newspaper app containing news from 10+ local news publishers in Hong Kong. Made with ❤
Stars: ✭ 82 (-52.87%)
Mutual labels:  realm
Predicateflow
Write amazing, strong-typed and easy-to-read NSPredicate.
Stars: ✭ 98 (-43.68%)
Mutual labels:  realm
Swift Zhi
iOS ZhiHuDaily client, implemented in Swift
Stars: ✭ 103 (-40.8%)
Mutual labels:  realm
Bibleify Desktop
🖥️Simple & fast bible app with dramatized audio built with Electron, React, Rematch & Realm
Stars: ✭ 70 (-59.77%)
Mutual labels:  realm
Realm Draw
The official Realm Draw app used in promotional videos
Stars: ✭ 150 (-13.79%)
Mutual labels:  realm
Todolist
A simple ToDoList written in Swift
Stars: ✭ 100 (-42.53%)
Mutual labels:  realm
Model2app
Turn your Swift data model into a working CRUD app.
Stars: ✭ 118 (-32.18%)
Mutual labels:  realm
Realm Dart Ffi
Experimental Realm binding using dart:ffi preview support
Stars: ✭ 83 (-52.3%)
Mutual labels:  realm
Bgfmdb
BGFMDB让数据的增删改查分别只需要一行代码即可,就是这么简单任性,本库几乎支持存储ios所有基本的自带数据类型.
Stars: ✭ 1,344 (+672.41%)
Mutual labels:  realm
Todo Android
[Google Play] Todo Android App using Realm, Material Design, and Dagger 2.
Stars: ✭ 107 (-38.51%)
Mutual labels:  realm
Keycloak Clojure
A Clojure library helping the integration of Keycloak with a Clojure Application + a sample SPA Client and API Server demonstrating the Keycloak integration
Stars: ✭ 81 (-53.45%)
Mutual labels:  realm
Realm Studio
Realm Studio
Stars: ✭ 134 (-22.99%)
Mutual labels:  realm
Android Mvp Starter
Create/Generate your MVP projects easily
Stars: ✭ 72 (-58.62%)
Mutual labels:  realm
Apiclient
A easy to use api client that combines the power of Retrofit, Realm, Gson, Rxjava and Retrolambda in a easy to use library for Java and Android
Stars: ✭ 100 (-42.53%)
Mutual labels:  realm
Rxrealmdatasources
An easy way to bind an RxRealm observable to a table or collection view
Stars: ✭ 154 (-11.49%)
Mutual labels:  realm
Nearbyweather
NearbyWeather is an open source weather app for iOS, which uses the OpenWeatherMap API. With this project developers are invited to learn advanced iOS concepts, as well as to contribute further advancements. Fork this repo to get started.
Stars: ✭ 146 (-16.09%)
Mutual labels:  realm
Autograph
A GraphQL Client in Swift
Stars: ✭ 117 (-32.76%)
Mutual labels:  realm

Realm Field Names Helper

This library auto-generate helper classes that can help make Realm queries more type safe.

For each Realm model class a corresponding <class>Fields class is created with static references to all queryable field names.

Installation

Just include the following dependency in your gradle.build file

// Android Java projects
annotationProcessor 'dk.ilios:realmfieldnameshelper:2.0.0'

// Android Kotlin projects
kapt 'dk.ilios:realmfieldnameshelper:2.0.0'

This library is compatible with Realm 1.1.1 and onwards.

Plugin order with Kotlin

When combining Realm and Kotlin, the order of plugins matter in order for everything to work correctly. Plugins should be applied in the following order:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'

dependencies {
    kapt 'dk.ilios:realmfieldnameshelper:2.0.0'
}

Usage

The library adds an annotation processor that automatically detects all Realm model classes and generated an extra class called <className>Fields. This class will contain static references to all field names that can be queried.

// Standard Realm Model class
public class Person extends RealmObject {
    private String name;
    private boolean hasDogs; // camel case naming gets converted to uppercase separated by "_"
    private boolean mHasCats; // Hungarian notation is evil but support for m starting prefix.
    private boolean has_fish; // fields already using "_" are just converted as they are.
    private Dog favoriteDog; // linked fields are generated one link away
    private RealmList<Dog> dogs; // linked fields are generated one link away

    @Ignore
    private int random;

    // Getters and setters ...
}

public class Dog extends RealmObject {
    private String name;

    // Getters and setters ...
}


// This class is automatically generated by this library
public class PersonFields {
    public static final String NAME = "name";
    public static final String HAS_DOGS = "hasDogs";
    public static final String HAS_CATS = "mHasCats";
    public static final String HAS_FISH = "has_fish";
    public static final class FAVORITE_DOG {
        public static final String $ = "favoriteDog"; // field name in parent object
        public static final String NAME = "favoriteDog.name";
    }
    public static final class DOGS {
        public static final String $ = "dogs"; // field name in parent object
        public static final String NAME = "dogs.name";
    }
}

// And can be used when creating queries
Realm realm = Realm.getDefaultInstance();
RealmResults<Person> results = realm.where(Person.class)
                                    .equalTo(PersonFields.NAME, "John")
                                    .findAll();

RealmResults<Person> results = realm.where(Person.class)
                                    .equalTo(PersonFields.FAVORITE_DOG.NAME, "Fido")
                                    .findAll();

You can also see an example here.

About this library

Even though I am a contributor to Realm, this project is not officially affiliated with Realm and was created purely to scratch an itch in a side project I was working on.

Use it with that it mind.

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].