From 8984db91f521bb6ed78d2cc1de12e8e920cb8098 Mon Sep 17 00:00:00 2001 From: Lior Mualem Date: Mon, 5 May 2014 13:38:56 +0300 Subject: [PATCH] Added gridfs-stream --- gridfs-stream/gridfs-stream.d.ts | 66 ++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 gridfs-stream/gridfs-stream.d.ts diff --git a/gridfs-stream/gridfs-stream.d.ts b/gridfs-stream/gridfs-stream.d.ts new file mode 100644 index 0000000000..11bc3adb20 --- /dev/null +++ b/gridfs-stream/gridfs-stream.d.ts @@ -0,0 +1,66 @@ +// Type definitions for gridfs-stream 0.5.0 +// Project: https://github.com/aheckmann/gridfs-stream +// Definitions by: Lior Mualem + +/* =================== USAGE =================== + + import express = require('express'); + var app = express(); + + =============================================== */ + +/// +/// + +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 { + } + + export interface ReadStream extends NodeJS.ReadableStream { + } +} + +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: mongo.Collection; + + 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); + exist(options: GridFSStream.Options, callback: (err: Error, found: boolean) => void); + } + } + + export = g; +} +