forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gridfs-stream.d.ts
70 lines (54 loc) · 2.02 KB
/
gridfs-stream.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Type definitions for gridfs-stream 0.5.0
// Project: https://github.com/aheckmann/gridfs-stream
// Definitions by: Lior Mualem <https://github.com/liorm/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
/// <reference path="../mongodb/mongodb.d.ts" />
declare module GridFSStream {
export interface Range {
startPos: number;
endPos: number;
}
export interface Options {
_id?: string;
filename?: string;
mode?: string;
range?: Range;
// any other options from the GridStore may be passed too, e.g.
chunkSize?: number;
content_type?: string;
root?: string;
metadata?: any;
}
export interface WriteStream extends NodeJS.WritableStream {
writable: boolean;
name: string;
id: string;
options: Options;
mode: string;
}
export interface ReadStream extends NodeJS.ReadableStream {
readable: boolean;
paused: boolean;
}
}
declare module "gridfs-stream" {
import mongo = require('mongodb');
// Merged declaration, g is both a callable function and a namespace
function g(db: any, mongo: any): g.Grid;
module g {
export class Grid {
files: mongo.Collection;
collection(name?: string): mongo.Collection;
curCol: string;
createWriteStream(options?: GridFSStream.Options): GridFSStream.WriteStream;
createReadStream(options?: GridFSStream.Options): GridFSStream.ReadStream;
createWriteStream(options?: string): GridFSStream.WriteStream;
createReadStream(options?: string): GridFSStream.ReadStream;
remove(options: GridFSStream.Options, callback: (err: Error) => void): void;
exist(options: GridFSStream.Options, callback: (err: Error, found: boolean) => void): void;
findOne(options: GridFSStream.Options, callback: (err: Error, record: any)=>void):void;
}
}
export = g;
}