1- import mongoose from "mongoose" ;
1+ // flow-typed signature: ff3cec7c93541c92294f76bebb0d2ee4
2+ // flow-typed version: 640b352228/mongoose_v4.x.x/flow_>=v0.50.x
3+
4+ /*** FIX broken globals import 'bson' (((( ***/
5+ // import 'bson';
6+ declare class bson$ObjectId {
7+ constructor ( id ?: string | number | bson$ObjectId ) : this ;
8+ generationTime : number ;
9+ static createFromHexString ( hexString : string ) : bson$ObjectId ;
10+ static createFromTime ( time : number ) : bson$ObjectId ;
11+ static isValid ( id ?: string | number | bson$ObjectId | null | void ) : boolean ;
12+ equals ( otherID : bson$ObjectId ) : boolean ;
13+ generate ( time ? : number ) : string ;
14+ getTimestamp ( ) : Date ;
15+ toHexString ( ) : string ;
16+ toString ( ) : string ;
17+ inspect ( ) : string ;
18+ toJSON ( ) : string ;
19+ }
20+ declare class bson$Decimal128 {
21+ constructor ( bytes : Buffer ) : this ;
22+ static fromString ( string : string ) : bson$Decimal128 ;
23+ toString ( ) : string ;
24+ toJSON ( ) : { $numberDecimal : string } ;
25+ }
26+ /*** end FIX broken globals import 'bson' (((( ***/
27+
28+ type MongoId = bson$ObjectId | string | number ;
229
3- type MongoId = BSONObjectId | string | number ;
30+ type Mongoose$Types = { |
31+ ObjectId : Class < bson$ObjectId > ,
32+ Mixed : Object ,
33+ Embedded : Object ,
34+ Document : Object ,
35+ DocumentArray : Object ,
36+ Subdocument : Object ,
37+ Array : Object ,
38+ Buffer : Object ,
39+ Decimal128 : Class < bson$Decimal128 >
40+ | } ;
441
542type SchemaFields = {
643 [ fieldName : string ] : any
@@ -34,13 +71,14 @@ type SchemaOpts<Doc> = {
3471 typeKey ?: string ,
3572 useNestedStrict ?: boolean ,
3673 validateBeforeSave ?: boolean ,
37- versionKey ?: string ,
74+ versionKey ?: string | false ,
3875 timestamps ?:
3976 | boolean
4077 | {
4178 createdAt ?: string ,
4279 updatedAt ?: string
43- }
80+ } ,
81+ discriminatorKey ?: string
4482} ;
4583
4684type IndexFields = {
@@ -57,32 +95,6 @@ type IndexOpts = {|
5795 weights ?: Object
5896| } ;
5997
60- declare class BSONObjectId {
61- constructor ( id ?: string | number | BSONObjectId ) : BSONObjectId ;
62- toHexString ( ) : string ;
63- toString ( ) : string ;
64- toJSON ( ) : string ;
65- inspect ( ) : string ;
66- equals ( otherId : string | number | BSONObjectId ) : boolean ;
67- getTimestamp ( ) : Date ;
68-
69- static createFromTime ( time : number ) : BSONObjectId ;
70- static createFromHexString ( str : string ) : BSONObjectId ;
71- static isValid ( id : string | number | BSONObjectId ) : boolean ;
72- }
73-
74- type Mongoose$Types = { |
75- ObjectId : Class < BSONObjectId > ,
76- Mixed : Object ,
77- Embedded : Object ,
78- Document : Object ,
79- DocumentArray : Object ,
80- Subdocument : Object ,
81- Array : Object ,
82- Buffer : Object ,
83- Decimal128 : Object
84- | } ;
85-
8698type Mongoose$SchemaMethods = {
8799 [ name : string ] : Function
88100} ;
@@ -170,7 +182,8 @@ type Mongoose$SchemaField<Schema> = {
170182 description : ?string
171183 } ,
172184 enumValues ?: ?( string [ ] ) ,
173- schema ?: Schema
185+ schema ?: Schema ,
186+ _index ?: ?{ [ optionName : string ] : mixed }
174187} ;
175188
176189declare class Mongoose$SchemaVirtualField {
@@ -220,7 +233,7 @@ declare class Mongoose$Document {
220233 data : Object ,
221234 options ? : Object
222235 ) : Mongoose$Query < ?this , this > ;
223- static count ( criteria : Object ) : Promise < number > ;
236+ static count ( criteria ? : Object ) : Promise < number > ;
224237 static remove ( criteria : Object ) : Promise < mixed > ;
225238 static update (
226239 criteria : Object ,
@@ -253,10 +266,12 @@ declare class Mongoose$Document {
253266 static modelName : string ;
254267 static schema : Mongoose$Schema < this > ;
255268 static on ( type : string , cb : Function ) : void ;
269+ static discriminator ( name : string , schema : Mongoose$Schema < any > ) : Class < this > ;
256270
271+ collection : Mongoose$Collection ;
257272 constructor ( data ?: $Shape < this > ) : this ;
258273 id : string | number ;
259- _id : MongoId ;
274+ _id : bson$ObjectId | string | number ;
260275 __v ?: number ;
261276 save ( ) : Promise < this > ;
262277 update ( update : Object , options ? : Object ) : Promise < UpdateResult > ;
@@ -346,7 +361,7 @@ declare class Mongoose$Query<Result, Doc> extends Promise<Result> {
346361 batchSize ( n : number ) : Mongoose$Query < Result , Doc > ;
347362 collation ( value : Object ) : Mongoose$Query < Result , Doc > ;
348363 comment ( val : string ) : Mongoose$Query < Result , Doc > ;
349- cursor ( opts : Object ) : Mongoose$QueryCursor < Doc > ;
364+ cursor ( opts ? : Object ) : Mongoose$QueryCursor < Doc > ;
350365 deleteMany ( criteria ? : Object ) : Mongoose$Query < any , Doc > ;
351366 deleteOne ( criteria ?: Object ) : Mongoose$Query < any , Doc > ;
352367 distinct ( field : string , criteria ? : Object ) : Mongoose$Query < Result , Doc > ;
@@ -407,7 +422,7 @@ declare class Mongoose$Query<Result, Doc> extends Promise<Result> {
407422
408423declare class Mongoose$QueryCursor < Doc > {
409424 on ( type : "data" | "end" | string , cb : Function ) : void ;
410- next ( cb : ( err : Error , doc : Doc ) = > void ) : void ;
425+ next ( cb ? : ( err : Error , doc : Doc ) = > void ) : Promise < ? Doc > ;
411426}
412427
413428declare class Mongoose$QueryStream {
@@ -483,14 +498,15 @@ declare class Mongoose$Connection {
483498}
484499
485500declare module "mongoose" {
486- declare export type MongooseConnection = Mongoose$Connection ;
487- declare export type MongoId = MongoId ;
488- declare export type BSONObjectId = BSONObjectId ;
489- declare export type MongooseQuery < Result , Doc> = Mongoose$Query < Result , Doc > ;
490- declare export type MongooseDocument = Mongoose$Document ;
491- declare export type MongooseModel = typeof Mongoose$Document ;
492- declare export type MongooseSchema < Doc > = Mongoose$Schema < Doc > ;
493- declare export type MongooseSchemaField < Schema > = Mongoose$SchemaField <
501+ declare type MongooseConnection = Mongoose$Connection ;
502+ declare type MongoId = MongoId ;
503+ declare type BSONObjectId = bson$ObjectId ;
504+ declare type ObjectId = bson$ObjectId ;
505+ declare type MongooseQuery < Result , Doc> = Mongoose$Query < Result , Doc > ;
506+ declare type MongooseDocument = Mongoose$Document ;
507+ declare type MongooseModel = typeof Mongoose$Document ;
508+ declare type MongooseSchema < Doc > = Mongoose$Schema < Doc > ;
509+ declare type MongooseSchemaField < Schema > = Mongoose$SchemaField <
494510 Schema
495511 > ;
496512
@@ -499,9 +515,9 @@ declare module "mongoose" {
499515 Types : Mongoose$Types ,
500516 Promise : any ,
501517 model : $PropertyType < Mongoose$Connection , "model" > ,
502- createConnection ( uri ?: string ) : Mongoose$Connection ,
518+ createConnection ( uri ?: string , options ?: Object ) : Mongoose$Connection ,
503519 set : ( key : string , value : string | Function | boolean ) => void ,
504- connect : Function ,
520+ connect : ( uri : string , options ? : Object ) => void ,
505521 connection : Mongoose$Connection ,
506522 connections : Mongoose$Connection [ ] ,
507523 Query : typeof Mongoose$Query ,
0 commit comments