Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6,258 changes: 106 additions & 6,152 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"version": "6.3.10",
"scripts": {
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"format": "prettier --write \"src/**/*.ts\""
"format": "prettier --write \"src/**/*.ts\"",
"build": "tsc"
},
"devDependencies": {
"@types/chai": "^4.3.5",
Expand Down
188 changes: 83 additions & 105 deletions src/GridFSPromise.d.ts
Original file line number Diff line number Diff line change
@@ -1,109 +1,87 @@
import { ObjectID } from 'bson';
import {
GridFSBucketReadStream,
MongoClient,
MongoClientOptions,
} from 'mongodb';
import { ObjectId } from 'bson';
import { Document, GridFSBucketReadStream, MongoClient, MongoClientOptions } from 'mongodb';
export interface IGridFSObject {
_id: ObjectID;
length: number;
chunkSize: number;
uploadDate: Date;
md5: string;
filename: string;
contentType: string;
metadata: object;
_id: ObjectId;
length: number;
chunkSize: number;
uploadDate: Date;
md5?: string;
filename: string;
contentType?: string | undefined;
metadata?: Document | undefined;
}
export declare class GridFSPromise {
set CONNECTION(value: MongoClient);
get connection(): MongoClient | null;
private databaseName;
private readonly connectionUrl;
private readonly mongoClientOptions;
private basePath;
private bucketName;
private closeConnectionAutomatically;
private _CONNECTION;
maxTimeMS: number;
/**
* Constructor
* @param {string} mongoUrl
* @param {string} databaseName
* @param {MongoClientOptions} mongoOptions
* @param {string} bucketName
* @param {string} basePath
* @param {boolean} closeConnectionAutomatically
*/
constructor(
databaseName: string,
mongoUrl?: string | null,
mongoOptions?: MongoClientOptions | null,
bucketName?: string,
basePath?: string,
closeConnectionAutomatically?: boolean,
);
/**
* Returns a stream of a file from the GridFS.
* @param {string} id
* @return {Promise<GridFSBucketReadStream>}
*/
getFileStream(id: string): Promise<GridFSBucketReadStream>;
/**
* Save the File from the GridFs to the filesystem and get the Path back
* @param {string} id
* @param {string} fileName
* @param {string} filePath
* @return {Promise<string>}
*/
getFile(id: string, fileName?: string, filePath?: string): Promise<string>;
/**
* Get a single Object
* @param {string} id
* @return {Promise<IGridFSObject>}
*/
getObject(id: string): Promise<IGridFSObject>;
/**
* Upload a file directly from a fs Path
* @param {string} uploadFilePath
* @param {string} targetFileName
* @param {string} type
* @param {object} meta
* @param {boolean} deleteFile
* @return {Promise<IGridFSObject>}
*/
uploadFile(
uploadFilePath: string,
targetFileName: string,
type: string,
meta: object,
deleteFile?: boolean,
): Promise<IGridFSObject>;
/**
* Upload a file directly from a fs Path
* @param {string} uploadData
* @param {string} targetFileName
* @param {string} type
* @param {object} meta
* @return {Promise<IGridFSObject>}
*/
uploadFileString(
uploadData: string,
targetFileName: string,
type: string,
meta: object,
): Promise<IGridFSObject>;
/**
* Delete an File from the GridFS
* @param {string} id
* @return {Promise<boolean>}
*/
delete(id: string): Promise<boolean>;
/**
* Close the Connection, if the connection is not needed anymore
*/
closeConnection(): Promise<boolean>;
/**
* Connect to the Database and return a promise Object
*/
private connectDB;
set CONNECTION(value: MongoClient);
get connection(): MongoClient | null;
private databaseName;
private readonly connectionUrl;
private readonly mongoClientOptions;
private basePath;
private bucketName;
private closeConnectionAutomatically;
private _CONNECTION;
maxTimeMS: number;
/**
* Constructor
* @param {string} mongoUrl
* @param {string} databaseName
* @param {MongoClientOptions} mongoOptions
* @param {string} bucketName
* @param {string} basePath
* @param {boolean} closeConnectionAutomatically
*/
constructor(databaseName: string, mongoUrl?: string | null, mongoOptions?: MongoClientOptions | null, bucketName?: string, basePath?: string, closeConnectionAutomatically?: boolean);
/**
* Returns a stream of a file from the GridFS.
* @param {string} id
* @return {Promise<GridFSBucketReadStream>}
*/
getFileStream(id: string): Promise<GridFSBucketReadStream>;
/**
* Save the File from the GridFs to the filesystem and get the Path back
* @param {string} id
* @param {string} fileName
* @param {string} filePath
* @return {Promise<string>}
*/
getFile(id: string, fileName?: string, filePath?: string): Promise<string>;
/**
* Get a single Object
* @param {string} id
* @return {Promise<IGridFSObject>}
*/
getObject(id: string): Promise<IGridFSObject | void>;
/**
* Upload a file directly from a fs Path
* @param {string} uploadFilePath
* @param {string} targetFileName
* @param {string} type
* @param {object} meta
* @param {boolean} deleteFile
* @return {Promise<IGridFSObject>}
*/
uploadFile(uploadFilePath: string, targetFileName: string, type: string, meta: object, deleteFile?: boolean): Promise<IGridFSObject>;
/**
* Upload a file directly from a fs Path
* @param {string} uploadData
* @param {string} targetFileName
* @param {string} type
* @param {object} meta
* @return {Promise<IGridFSObject>}
*/
uploadFileString(uploadData: string, targetFileName: string, type: string, meta: object): Promise<IGridFSObject>;
/**
* Delete an File from the GridFS
* @param {string} id
* @return {Promise<boolean>}
*/
delete(id: string): Promise<boolean>;
/**
* Close the Connection, if the connection is not needed anymore
*/
closeConnection(): Promise<boolean>;
/**
* Connect to the Database and return a promise Object
*/
private connectDB;
}
Loading