import { FetchOptions, OrmDriver } from "../OrmDriver"; import { Entity, EntityClass, MaybeEntityClass } from "../utils"; import Query from "../Query"; import Collection from "../Collection"; import { ISubscription } from "rxjs/Subscription"; import { IFieldObject } from '../IFieldObject'; export declare type StoreItem = { model: Entity; attributes: IFieldObject; changes: IFieldObject | null; }; export default class SimpleOrm implements OrmDriver { _lastId: number; _store: { "byCid": { [cid: string]: Entity; }; "byId": { [model: string]: { [id: string]: string; }; }; }; constructor(opts?: { executeQuery: (modelClass: EntityClass, query: Query) => Promise; observeQuery: (modelClass: EntityClass, query: Query) => void; }); /** * gets the model by its id or null if doesn't exists */ getModelById(model: MaybeEntityClass, id: string | number, options?: FetchOptions): Promise; /** * gets the cid of the model with the passed id if the relative model is already fetched, null otherwise */ getModelByCid(cid: string): Entity | null; getCidById(model: MaybeEntityClass, id: string | number): string | null; /** * Upserts the model in the ORM */ save(model: Entity, collection?: Collection): Promise; /** * Removes the model in the ORM */ delete(model: Entity, collection?: Collection): Promise; observeQuery(model: EntityClass, query: Query, handler: (array: T[]) => void): ISubscription; executeQuery(model: EntityClass, query: Query): Promise; find(model: MaybeEntityClass): Query; }