vadimdemedes / mongorito

🍹 MongoDB ODM for Node.js apps based on Redux
1.38k stars 90 forks source link

Type definition for intellisense #207

Open wesleycoder opened 6 years ago

wesleycoder commented 6 years ago

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

adieuadieu commented 6 years ago

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>
  }
}