Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save netspencer/dec39a099009218aa49b60b8127eb418 to your computer and use it in GitHub Desktop.
Save netspencer/dec39a099009218aa49b60b8127eb418 to your computer and use it in GitHub Desktop.
flowtype interface for realm-js
declare class RealmResults {
length:number;
filtered(query:string, arg:?any):RealmResults;
snapshot():RealmResults;
sorted(descriptor:any, reverse:?boolean):RealmResults;
}
declare class RealmList {
length:number;
filtered(query:string, arg:?any):RealmResults;
pop():Object|undefined;
push(...object:Object):number;
shift():Object|undefined;
snapshot():RealmResults;
sorted(descriptor:any, reverse:?boolean):RealmResults;
unshift(...object:Object):number;
}
declare type RealmObjectSchemaProperty = {
type:string;
objectType:?string;
default:?any;
optional:?boolean;
}
declare type RealmObjectSchema = {
name:string;
primaryKey:?string;
properties:any;
}
declare type RealmConfiguration = {
path:?string;
schema:?RealmObjectSchema;
schemaVersion:?number;
}
declare class Realm {
defaultPath:string;
constructor(config:?RealmConfiguration):void;
addListener(name:string, callback:()=>void);
create(type:string, properties:Object, update:?boolean):Object;
delete(object:Object|Array<Object>|RealmList|RealmResults):void;
deleteAll():void;
objects(type:string):RealmResults;
removeAllListeners(name:?string):void;
write(callback:()=>void);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment