mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-07 22:38:13 +08:00
Add id to mongodb gridfs upload streams (#22930)
As seen in http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#openUploadStream: ```js var uploadStream = bucket.openUploadStream('test.dat'); var license = fs.readFileSync('./LICENSE'); var id = uploadStream.id; ``` The resulting stream from `openUploadStream` *has* an id.
This commit is contained in:
committed by
Wesley Wigham
parent
5076877fc7
commit
17d8fcc76f
12
types/mongodb/index.d.ts
vendored
12
types/mongodb/index.d.ts
vendored
@@ -31,7 +31,7 @@ export class MongoClient extends EventEmitter {
|
||||
static connect(uri: string, callback: MongoCallback<MongoClient>): void;
|
||||
static connect(uri: string, options?: MongoClientOptions): Promise<MongoClient>;
|
||||
static connect(uri: string, options: MongoClientOptions, callback: MongoCallback<MongoClient>): void;
|
||||
/**
|
||||
/**
|
||||
* @deprecated
|
||||
* http://mongodb.github.io/node-mongodb-native/3.0/api/MongoClient.html#connect
|
||||
*/
|
||||
@@ -830,7 +830,7 @@ export interface CollectionAggregationOptions {
|
||||
collation?: Object;
|
||||
comment?: string
|
||||
session?: ClientSession;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#insertMany */
|
||||
@@ -1353,7 +1353,7 @@ export class GridFSBucket {
|
||||
/** http://mongodb.github.io/node-mongodb-native/3.0/api/GridFSBucket.html#openUploadStream */
|
||||
openUploadStream(filename: string, options?: GridFSBucketOpenUploadStreamOptions): GridFSBucketWriteStream;
|
||||
/** http://mongodb.github.io/node-mongodb-native/3.0/api/GridFSBucket.html#openUploadStreamWithId */
|
||||
openUploadStreamWithId(id: string | number | Object, filename: string, options?: GridFSBucketOpenUploadStreamOptions): GridFSBucketWriteStream;
|
||||
openUploadStreamWithId(id: GridFSBucketWriteStreamId, filename: string, options?: GridFSBucketOpenUploadStreamOptions): GridFSBucketWriteStream;
|
||||
/** http://mongodb.github.io/node-mongodb-native/3.0/api/GridFSBucket.html#rename */
|
||||
rename(id: ObjectID, filename: string, callback?: GridFSBucketErrorCallback): void;
|
||||
}
|
||||
@@ -1391,6 +1391,7 @@ export interface GridFSBucketOpenUploadStreamOptions {
|
||||
|
||||
/** https://mongodb.github.io/node-mongodb-native/3.0/api/GridFSBucketReadStream.html */
|
||||
export class GridFSBucketReadStream extends Readable {
|
||||
id: ObjectID;
|
||||
constructor(chunks: Collection<any>, files: Collection<any>, readPreference: Object, filter: Object, options?: GridFSBucketReadStreamOptions);
|
||||
}
|
||||
|
||||
@@ -1404,14 +1405,17 @@ export interface GridFSBucketReadStreamOptions {
|
||||
|
||||
/** https://mongodb.github.io/node-mongodb-native/3.0/api/GridFSBucketWriteStream.html */
|
||||
export class GridFSBucketWriteStream extends Writable {
|
||||
id: GridFSBucketWriteStreamId;
|
||||
constructor(bucket: GridFSBucket, filename: string, options?: GridFSBucketWriteStreamOptions);
|
||||
}
|
||||
|
||||
/** https://mongodb.github.io/node-mongodb-native/3.0/api/GridFSBucketWriteStream.html */
|
||||
export interface GridFSBucketWriteStreamOptions {
|
||||
id?: string | number | Object,
|
||||
id?: GridFSBucketWriteStreamId,
|
||||
chunkSizeBytes?: number,
|
||||
w?: number,
|
||||
wtimeout?: number,
|
||||
j?: number
|
||||
}
|
||||
|
||||
type GridFSBucketWriteStreamId = string | number | Object | ObjectID;
|
||||
|
||||
8
types/mongodb/v2/index.d.ts
vendored
8
types/mongodb/v2/index.d.ts
vendored
@@ -1371,7 +1371,7 @@ export class GridFSBucket {
|
||||
// http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#openUploadStream
|
||||
openUploadStream(filename: string, options?: GridFSBucketOpenUploadStreamOptions): GridFSBucketWriteStream;
|
||||
// http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#openUploadStreamWithId
|
||||
openUploadStreamWithId(id: string | number | Object, filename: string, options?: GridFSBucketOpenUploadStreamOptions): GridFSBucketWriteStream;
|
||||
openUploadStreamWithId(id: GridFSBucketWriteStreamId, filename: string, options?: GridFSBucketOpenUploadStreamOptions): GridFSBucketWriteStream;
|
||||
// http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#rename
|
||||
rename(id: ObjectID, filename: string, callback?: GridFSBucketErrorCallback): void;
|
||||
}
|
||||
@@ -1409,6 +1409,7 @@ export interface GridFSBucketOpenUploadStreamOptions {
|
||||
|
||||
// https://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucketReadStream.html
|
||||
export class GridFSBucketReadStream extends Readable {
|
||||
id: ObjectID;
|
||||
constructor(chunks: Collection<any>, files: Collection<any>, readPreference: Object, filter: Object, options?: GridFSBucketReadStreamOptions);
|
||||
}
|
||||
|
||||
@@ -1422,14 +1423,17 @@ export interface GridFSBucketReadStreamOptions {
|
||||
|
||||
// https://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucketWriteStream.html
|
||||
export class GridFSBucketWriteStream extends Writable {
|
||||
id: GridFSBucketWriteStreamId;
|
||||
constructor(bucket: GridFSBucket, filename: string, options?: GridFSBucketWriteStreamOptions);
|
||||
}
|
||||
|
||||
// https://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucketWriteStream.html
|
||||
export interface GridFSBucketWriteStreamOptions {
|
||||
id?: string | number | Object,
|
||||
id?: GridFSBucketWriteStreamId,
|
||||
chunkSizeBytes?: number,
|
||||
w?: number,
|
||||
wtimeout?: number,
|
||||
j?: number
|
||||
}
|
||||
|
||||
type GridFSBucketWriteStreamId = string | number | Object | ObjectID;
|
||||
|
||||
Reference in New Issue
Block a user