React native Realm Model
RealmModel is a wrapper for realm.
CHANGELOG
- 0.0.10
- Fixed some bugs
- Supported model events: beforeInsert, afterInsert, beforeUpdate, afterUpdate, beforeRemove, afterRemove
static realm = realm;static {doccreatedAt = docupdatedAt = ;return doc;}
How it works
;;const realm = schema: name: 'Product' properties: title: 'string' content: type: 'string' optional: true price: 'int' static realm = realm; // custom methods { return thisprice + 'vnđ'; } Product;var product = Product; console; product console; product;
API
find(selector: Object, option: Object) -> Array
-
selector is search criteria
- Type 1:
{field: value}
- Type 2: logical operator
{$or: [{field1: value1, field2: value2}]}
- Type 3: realm operator
==
,>=
,<=
,>
,<
,BEGINSWITH
,ENDSWITH
,CONTAINS
and string comparisons can be made case insensitive by appending[c]
to the operator:==[c]
,BEGINSWITH[c]
etc.
Ex:
Product.find({title: {'BEGINSWITH[c]': 'hello'}})
- Type 1:
-
option is search option support:
limit
,offset
,sort