Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript support #1

Closed
nkaredia opened this issue Jan 15, 2017 · 2 comments
Closed

Typescript support #1

nkaredia opened this issue Jan 15, 2017 · 2 comments

Comments

@nkaredia
Copy link

Implement typescript support for angular2 and ionic2 projects.

@erikolson186 erikolson186 self-assigned this Jan 18, 2017
@erikolson186
Copy link
Owner

erikolson186 commented Feb 2, 2017

I just now created a TypeScript declaration. If you would review and test it to see if it meets your requirements, I would appreciate it.

/// <reference types="node" />

declare module "zangodb" {
    export interface Callback { (error: Error): void; }
    export interface ResultCallback<T> { (error: Error, result: T): void; }
    export interface IteratorCallback { (doc: any): void; }

    export class Cursor extends NodeJS.EventEmitter {
        filter(expr: Object): Cursor;
        forEach(fn: IteratorCallback, cb?: Callback): Promise<Object>;
        group(spec: Object): Cursor;
        hint(path: string): Cursor;
        limit(num: number): Cursor;
        project(spec: Object): Cursor;
        skip(num: number): Cursor;
        sort(spec: Object): Cursor;
        toArray(cb?: ResultCallback<Object[]>): Promise<Object[]>;
        unwind(path: string): Cursor;
    }

    export class Collection {
        name: string;

        aggregate(pipeline: Object[]): Cursor;
        find(expr: Object, projection_spec?: Object): Cursor;
        insert(docs: Object|Object[], cb?: Callback): Promise<void>;
        remove(expr: Object, cb?: Callback): Promise<void>;
        update(expr: Object, spec: Object, cb?: Callback): Promise<void>;
    }

    export class Db extends NodeJS.EventEmitter {
        constructor(name: string, version?: number, config?: string[]|Object);

        name: string;
        version: number;

        close(): void;
        collection(name: string): Collection;
        drop(cb?: Callback): Promise<void>;
    }
}

@nkaredia
Copy link
Author

nkaredia commented Apr 5, 2017

@erikolson186 Thanks for the interface, ill extend it as per my requirement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants