JSPM

  • Created
  • Published
  • Downloads 827
  • Score
    100M100P100Q117712F
  • License MIT

TypeScript definitions for gridfs-stream

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@types/gridfs-stream) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Installation

    npm install --save @types/gridfs-stream

    Summary

    This package contains type definitions for gridfs-stream (https://github.com/aheckmann/gridfs-stream).

    Details

    Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/gridfs-stream.

    index.d.ts

    /// <reference types="node" />
    
    declare namespace GridFSStream {
        export interface Range {
            startPos: number;
            endPos: number;
        }
    
        export interface Options {
            _id?: string | undefined;
            filename?: string | undefined;
            mode?: string | undefined;
    
            range?: Range | undefined;
    
            // any other options from the GridStore may be passed too, e.g.
            chunkSize?: number | undefined;
            content_type?: string | undefined;
            root?: string | undefined;
            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;
        }
    }
    
    import mongo = require("mongodb");
    
    // Merged declaration, g is both a callable function and a namespace
    declare function g(db: any, mongo: any): g.Grid;
    
    declare namespace 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;
    

    Additional Details

    Credits

    These definitions were written by Lior Mualem.