mongorito icon indicating copy to clipboard operation
mongorito copied to clipboard

Type definition for intellisense

Open wesleycoder opened this issue 7 years ago • 1 comments

I use VSCode and i supports intellisense. But Mongorito doesn't expose type definitions yet.

So I'm requesting it here.

You could expose it through the DefinitelyTyped project

wesleycoder avatar Jan 31 '18 16:01 wesleycoder

Here's an incomplete head start:

declare module 'mongorito' {
  export const DBRef
  export const ObjectId
  export const Database

  export class Model {
    constructor(initialData: { [key: string]: any })
    public get(field?: string): any
    public set(field: string | any, value?: any): any
    public save(fields?: { [key: string]: any }): Promise<any>
    public collection(): string
    public static query(
      method: string,
      queries: ReadonlyArray<any>,
    ): Promise<any>
    public static include(fields?: ReadonlyArray<string>): any
    public static find(query?: { [key: string]: any }): Promise<Model>
    public static findOne(query?: { [key: string]: any }): Promise<Model>
    public static findById(id: ObjectId): Promise<Model>
  }
}

adieuadieu avatar Jan 31 '18 18:01 adieuadieu