All Projects → airamrguez → cordova-plugin-realm

airamrguez / cordova-plugin-realm

Licence: Apache-2.0 license
Unofficial Cordova plugin for Realm Mobile Database.

Programming Languages

objective c
16641 projects - #2 most used programming language
javascript
184084 projects - #8 most used programming language
java
68154 projects - #9 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to cordova-plugin-realm

Realm Js
Realm is a mobile database: an alternative to SQLite & key-value stores
Stars: ✭ 4,648 (+15927.59%)
Mutual labels:  realm, realm-mobile-database
o-fish-realm
Realm application code and sample data for the Officer's Fishery Information Sharing Hub (O-FISH). The mobile app allows fisheries officers to document and share critical information gathered during a routine vessel inspection. The web app allows agencies to gain insights from the aggregated information.
Stars: ✭ 23 (-20.69%)
Mutual labels:  realm, realm-mobile-database
ExamplesAndroid
Simple Example of Android [APIFacebook,APIGoogleMaps,APITwitter,Volley,Picasso etc etc etc]
Stars: ✭ 24 (-17.24%)
Mutual labels:  realm
authorizer
Your data, your control. Fully open source, authentication and authorization. No lock-ins. Deployment in Railway in 120 seconds || Spin a docker image as a micro-service in your infra. Built in login page and Admin panel out of the box.
Stars: ✭ 770 (+2555.17%)
Mutual labels:  nosql
nuxt-cordova-app
📱 Nuxt JS (Vue JS) + Vuetify 2 SPA hybrid demo app built using Cordova
Stars: ✭ 48 (+65.52%)
Mutual labels:  cordova
unqlite.rs
UnQLite wrapper 1.0 is avaliable for Rust
Stars: ✭ 99 (+241.38%)
Mutual labels:  nosql
cordova-plugin-facebook4
Use the latest Facebook SDK in your Cordova and Ionic projects
Stars: ✭ 772 (+2562.07%)
Mutual labels:  cordova
cordova-plugin-downloadmanager
A Cordova plugin to download file in system's default download manager
Stars: ✭ 45 (+55.17%)
Mutual labels:  cordova
cordova-plugin-amap
Amap Maps plugin for Cordova
Stars: ✭ 51 (+75.86%)
Mutual labels:  cordova
cordova-serve
Apache Cordova Serve Library
Stars: ✭ 15 (-48.28%)
Mutual labels:  cordova
ionic4-boilerplate
🚀 boilerplate for ionic4 with CI based on travis and fastlane. doc and example are provided
Stars: ✭ 25 (-13.79%)
Mutual labels:  cordova
grandnode2
Free, Open source, Fast, Headless, Multi-tenant eCommerce platform built with .NET Core, MongoDB, AWS DocumentDB, Azure CosmosDB, LiteDB, Vue.js.
Stars: ✭ 626 (+2058.62%)
Mutual labels:  nosql
soda-for-java
SODA (Simple Oracle Document Access) for Java is an Oracle library for writing Java apps that work with JSON (and not only JSON!) in the Oracle Database. SODA allows your Java app to use the Oracle Database as a NoSQL document store.
Stars: ✭ 61 (+110.34%)
Mutual labels:  nosql
Noodle
Simple object storage for Android
Stars: ✭ 55 (+89.66%)
Mutual labels:  nosql
workshop-intro-to-cassandra
Learn Apache Cassandra fundamentals in this hands-on workshop
Stars: ✭ 208 (+617.24%)
Mutual labels:  nosql
dynobase
Dynobase - Professional GUI Client for DynamoDB (releases / issues / roadmap repository) https://dynobase.dev
Stars: ✭ 66 (+127.59%)
Mutual labels:  nosql
gorm-neo4j
GORM for Neo4j
Stars: ✭ 16 (-44.83%)
Mutual labels:  nosql
ionic3-angular4-sample-app
Sample app of Ionic 3 and Angular 4
Stars: ✭ 35 (+20.69%)
Mutual labels:  cordova
hms-cordova-plugin
This repo contains all of Cordova HMS plugins.
Stars: ✭ 78 (+168.97%)
Mutual labels:  cordova
ionic-hockeyapp
Need HockeyApp in your Ionic application, add this package!
Stars: ✭ 19 (-34.48%)
Mutual labels:  cordova

@airamrguez/cordova-plugin-realm

IMPORTANT: This is not an official Realm product.

This is a Work In Progress. DO NOT USE IT. The API will change.

About

This plugin provides an interface to Realm mobile database for iOS, Android and the browser.

Installation

cordova plugin add https://github.com/airamrguez/cordova-plugin-realm

Browser

On your project root directory add the browser platform:

cordova platform add browser

Install @airamrguez/cdv-realm (not yet on npm) and launch it before working on the browser.

npm install -g cordova-realm-server
cdv-realm

See the Workflow section below to see how to start using Realm in Cordova.

Workflow

cordova-plugin-realm workflow

Usage

Schema definitions

Create a file named realmrc.json under your Cordova project root directory.

{
  "schemas": [{
    "name": "Person",
    "primaryKey": "id",
    "properties": {
      "id": "int",
      "name": { "type": "string", "indexed": true },
      "birthday": { "type": "date", "optional": true },
      "car": { "type": "Car" }
    }
  }, {
    "name": "Car",
    "properties": {
      "make": "string",
      "model": "string"
    }
  }]
}

This plugin uses realmrc.json file to generate native classes. Be sure you have added a platform to your project and build it every time you change your schema definition.

cordova platform add ios android
cordova build

Initialization

Realm plugin files are exposed under cordova.plugins.realm.

var Realm = cordova.plugins.realm;

Realm.init({ schema: ['Person', 'Car'] }, function(realm) {
  realm.create('Person', json, true, function(success, error) {
    if (error) {
      alert('Error committing into the database.');
      return;
    }
  });
});

Inserts and updates

var people = [{
  id: 1,
  name: "Joanne"
}, {
  id: 2,
  name: "Airam"
}];
realm.create('Person', people, true, function() {
  console.log('inserted');
}, function () {
  console.error('error');
});

Queries

Queries are created using the builder pattern.

Get all rows from a collection:

realm.where('Person')
  .findAll(function(results) {
    if (results.length > 0) {
      console.log('First result: ', results[0]);
      results.map(function(result) {
        // Do something with result...
      });
    }
  });

Write complex queries and get the results sorted by a field.

realm.where('Person')
  .between('age', 18, 39)
  .beginGroup()
    .equalTo('name', 'Peter', Realm.Types.Case.SENSITIVE)
    .or()
    .contains('name', 'Jo')
  .endGroup()
  .isNotEmpty('surnames')
  .findAllSorted('age', function(results) {
    results.forEach(function(result, i) {
      console.log('Result ', i, result);
    });
  });

Deletes

realm.where('Task').equalTo('id', 4).delete(() => {
  console.log('Task with id', 4, 'deleted.');
});

Results

Queries returns an array of results.

realm.where('Person')
  .findAll(function(results) {
    if (results.length > 0) {
      console.log('First result: ', results[0]);
      results.map(function(result) {
        // Do something with result...
      });
    }
  });

API

Realm

Realm class methods.

  • init({ schema: RealmSchema })

Realm instance methods.

  • where(schemaName: string): QueryBuilder returns a query object which you can use to append query methods.
  • create(schemaName: string, json: Array | Object, update: boolean, success, error): create or update an array or an object into the database.
  • deleteAll(schemaName) clears all objects.

Queries

Queries methods are auto-explanatory. Each condition of the query is implicitly logical-and together.

  • between(fieldName, from, to)
  • greaterThan(fieldName, value)
  • lessThan(fieldName, value)
  • greaterThanOrEqualTo(fieldName, value)
  • lessThanOrEqualTo(fieldName, value)
  • equalTo(fieldName, value, casing = cordova.plugins.Realm.Types.Case.INSENSITIVE)
  • notEqualTo(fieldName, value, casing = cordova.plugins.Realm.Types.Case.INSENSITIVE)
  • contains(fieldName, value, casing = cordova.plugins.Realm.Types.Case.INSENSITIVE)
  • beginsWith(fieldName, value, casing = cordova.plugins.Realm.Types.Case.INSENSITIVE)
  • endsWith(fieldName, value, casing = cordova.plugins.Realm.Types.Case.INSENSITIVE)
  • isNull(fieldName)
  • isNotNull(fieldName)
  • isEmpty(fieldName)
  • isNotEmpty(fieldName)

Join or negate conditions.

  • or()
  • not()

Add left parenthesis or right parenthesis with:

  • beginGroup()
  • endGroup()

End up your query with one of the following methods:

  • findAll(success)
  • findAllSorted(fieldName, success)
  • findAllSorted(fieldName, sorting = cordova.plugins.realm.Types.Sort.ASCENDING, success)
  • findAllSorted(fieldName: Array<string>, sorting: Array<cordova.plugins.realm.Types.Sort.ASCENDING>, success)
  • delete(success)
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].