Skip to content

Instantly share code, notes, and snippets.

@PyYoshi
Last active November 28, 2016 21:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save PyYoshi/457750f253acc1c3e511 to your computer and use it in GitHub Desktop.
Save PyYoshi/457750f253acc1c3e511 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