forked from hermesdj/mongoose-gridfs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial version for lenne.Tech projects
- Loading branch information
Showing
9 changed files
with
2,707 additions
and
13,049 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- '*/*' | ||
- '*' | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [18.15] | ||
mongodb-version: [4.4] | ||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use Node.js 18.15 | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 18.15 | ||
|
||
- name: Start MongoDB | ||
uses: supercharge/[email protected] | ||
with: | ||
mongodb-version: 4.4 | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
#- name: Optimize and check | ||
# run: npm run prepublishOnly | ||
|
||
- name: Build | ||
run: npm run build | ||
|
||
- name: Save build | ||
uses: actions/upload-artifact@v1 | ||
with: | ||
name: build | ||
path: . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Publish | ||
|
||
on: | ||
release: | ||
types: | ||
- released | ||
|
||
jobs: | ||
publish: | ||
name: Publish | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [16.13] | ||
mongodb-version: [4.4] | ||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use Node.js 16.13 | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 16.13 | ||
|
||
- name: Start MongoDB | ||
uses: supercharge/[email protected] | ||
with: | ||
mongodb-version: 4.4 | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
#- name: Optimize and check | ||
# run: npm run prepublishOnly | ||
|
||
- name: Build | ||
run: npm run build | ||
|
||
- uses: JS-DevTools/npm-publish@v1 | ||
with: | ||
access: public | ||
token: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,7 +112,7 @@ function createFileSchema(bucket) { | |
* @name read | ||
* @description Read file from MongoDB GridFS | ||
* @param {object} optns valid criteria for read existing file. | ||
* @param {number} [optns.revision=-1] The revision number relative to the | ||
* @param {number} [optns.revision] The revision number relative to the | ||
* oldest file with the given filename. 0 gets you the oldest file, 1 gets you | ||
* the 2nd oldest, -1 gets you the newest. | ||
* @param {number} [optns.start] Optional 0-based offset in bytes to start | ||
|
@@ -244,7 +244,7 @@ function createFileSchema(bucket) { | |
* @param {object} optns valid criteria for read existing file. | ||
* @param {object} optns._id The id of the file doc | ||
* @param {string} [optns.filename] The name of the file doc to stream | ||
* @param {number} [optns.revision=-1] The revision number relative to the | ||
* @param {number} [optns.revision] The revision number relative to the | ||
* oldest file with the given filename. 0 gets you the oldest file, 1 gets you | ||
* the 2nd oldest, -1 gets you the newest. | ||
* @param {number} [optns.start] Optional 0-based offset in bytes to start | ||
|
@@ -417,7 +417,7 @@ Object.defineProperty(GridFSBucket.prototype, 'collectionName', { | |
* document's `contentType` field. | ||
* @param {Array} [optns.aliases] Optional array of strings to store in the | ||
* file document's `aliases` field. | ||
* @param {boolean} [optns.disableMD5=false] If true, disables adding an | ||
* @param {boolean} [optns.disableMD5] If true, disables adding an | ||
* md5 field to file data. | ||
* @returns {object} Valid mongodb `GridFSBucketWriteStream` | ||
* @author lally elias <[email protected]> | ||
|
@@ -465,7 +465,7 @@ GridFSBucket.prototype.createWriteStream = function createWriteStream(optns) { | |
* @param {object} [optns] Valid options for read existing file. | ||
* @param {ObjectId} optns._id The id of the file doc | ||
* @param {string} [optns.filename] The name of the file doc to stream | ||
* @param {number} [optns.revision=-1] The revision number relative to the | ||
* @param {number} [optns.revision] The revision number relative to the | ||
* oldest file with the given filename. 0 gets you the oldest file, 1 gets you | ||
* the 2nd oldest, -1 gets you the newest. | ||
* @param {number} [optns.start] Optional 0-based offset in bytes to start | ||
|
@@ -587,7 +587,7 @@ GridFSBucket.prototype.writeFile = function writeFile(file, readstream, done) { | |
* @param {object} optns valid criteria for read existing file. | ||
* @param {object} optns._id The id of the file doc | ||
* @param {string} [optns.filename] The name of the file doc to stream | ||
* @param {number} [optns.revision=-1] The revision number relative to the | ||
* @param {number} [optns.revision] The revision number relative to the | ||
* oldest file with the given filename. 0 gets you the oldest file, 1 gets you | ||
* the 2nd oldest, -1 gets you the newest. | ||
* @param {number} [optns.start] Optional 0-based offset in bytes to start | ||
|
@@ -659,9 +659,13 @@ GridFSBucket.prototype.readFile = function readFile(optns, done) { | |
* bucket.deleteFile(_id, (error, results) => { ... }); | ||
*/ | ||
GridFSBucket.prototype.deleteFile = function deleteFile(_id, done) { | ||
this.delete(_id, function afterDelete(error) { | ||
return done(error, _id); | ||
}); | ||
this.delete(_id) | ||
.then(() => { | ||
done(undefined, _id); | ||
}) | ||
.catch((err) => { | ||
done(err, _id); | ||
}); | ||
}; | ||
|
||
GridFSBucket.prototype.unlink = GridFSBucket.prototype.deleteFile; | ||
|
@@ -835,11 +839,11 @@ GridFSBucket.prototype._removeFile = function _removeFile(request, file, done) { | |
* @name createBucket | ||
* @description Create GridFSBucket | ||
* @param {object} [optns] Optional settings. | ||
* @param {object} [optns.connection = mongoose.connection] A valid | ||
* @param {object} [optns.connection] A valid | ||
* instance of mongoose connection. | ||
* @param {string} [optns.bucketName="fs"] The 'files' and 'chunks' collections | ||
* @param {string} [optns.bucketName] The 'files' and 'chunks' collections | ||
* will be prefixed with the bucket name followed by a dot. | ||
* @param {number} [optns.chunkSizeBytes=255 * 1024] Number of bytes stored in | ||
* @param {number} [optns.chunkSizeBytes] Number of bytes stored in | ||
* each chunk. Defaults to 255KB | ||
* @param {object} [optns.writeConcern] Optional write concern to be passed to | ||
* write operations, for instance `{ w: 1 }` | ||
|
@@ -880,13 +884,13 @@ function createBucket(optns = {}) { | |
* @name createModel | ||
* @description Create GridFSBucket files collection model | ||
* @param {object} [optns] Optional settings. | ||
* @param {object} [optns.connection = mongoose.connection] A valid instance | ||
* @param {object} [optns.connection] A valid instance | ||
* of mongoose connection. | ||
* @param {string} [optns.modelName="File"] Valid model name to use with | ||
* @param {string} [optns.modelName] Valid model name to use with | ||
* mongoose | ||
* @param {string} [optns.bucketName="fs"] The 'files' and 'chunks' collections | ||
* @param {string} [optns.bucketName] The 'files' and 'chunks' collections | ||
* will be prefixed with the bucket name followed by a dot. | ||
* @param {number} [optns.chunkSizeBytes=255 * 1024] Number of bytes stored in | ||
* @param {number} [optns.chunkSizeBytes] Number of bytes stored in | ||
* each chunk. Defaults to 255KB | ||
* @param {object} [optns.writeConcern] Optional write concern to be passed to | ||
* write operations, for instance `{ w: 1 }` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,7 +113,7 @@ function createFileSchema(bucket) { | |
* @name read | ||
* @description Read file from MongoDB GridFS | ||
* @param {object} optns valid criteria for read existing file. | ||
* @param {number} [optns.revision=-1] The revision number relative to the | ||
* @param {number} [optns.revision] The revision number relative to the | ||
* oldest file with the given filename. 0 gets you the oldest file, 1 gets you | ||
* the 2nd oldest, -1 gets you the newest. | ||
* @param {number} [optns.start] Optional 0-based offset in bytes to start | ||
|
@@ -245,7 +245,7 @@ function createFileSchema(bucket) { | |
* @param {object} optns valid criteria for read existing file. | ||
* @param {object} optns._id The id of the file doc | ||
* @param {string} [optns.filename] The name of the file doc to stream | ||
* @param {number} [optns.revision=-1] The revision number relative to the | ||
* @param {number} [optns.revision] The revision number relative to the | ||
* oldest file with the given filename. 0 gets you the oldest file, 1 gets you | ||
* the 2nd oldest, -1 gets you the newest. | ||
* @param {number} [optns.start] Optional 0-based offset in bytes to start | ||
|
@@ -418,7 +418,7 @@ Object.defineProperty(mongooseCommon.GridFSBucket.prototype, 'collectionName', { | |
* document's `contentType` field. | ||
* @param {Array} [optns.aliases] Optional array of strings to store in the | ||
* file document's `aliases` field. | ||
* @param {boolean} [optns.disableMD5=false] If true, disables adding an | ||
* @param {boolean} [optns.disableMD5] If true, disables adding an | ||
* md5 field to file data. | ||
* @returns {object} Valid mongodb `GridFSBucketWriteStream` | ||
* @author lally elias <[email protected]> | ||
|
@@ -466,7 +466,7 @@ mongooseCommon.GridFSBucket.prototype.createWriteStream = function createWriteSt | |
* @param {object} [optns] Valid options for read existing file. | ||
* @param {ObjectId} optns._id The id of the file doc | ||
* @param {string} [optns.filename] The name of the file doc to stream | ||
* @param {number} [optns.revision=-1] The revision number relative to the | ||
* @param {number} [optns.revision] The revision number relative to the | ||
* oldest file with the given filename. 0 gets you the oldest file, 1 gets you | ||
* the 2nd oldest, -1 gets you the newest. | ||
* @param {number} [optns.start] Optional 0-based offset in bytes to start | ||
|
@@ -588,7 +588,7 @@ mongooseCommon.GridFSBucket.prototype.writeFile = function writeFile(file, reads | |
* @param {object} optns valid criteria for read existing file. | ||
* @param {object} optns._id The id of the file doc | ||
* @param {string} [optns.filename] The name of the file doc to stream | ||
* @param {number} [optns.revision=-1] The revision number relative to the | ||
* @param {number} [optns.revision] The revision number relative to the | ||
* oldest file with the given filename. 0 gets you the oldest file, 1 gets you | ||
* the 2nd oldest, -1 gets you the newest. | ||
* @param {number} [optns.start] Optional 0-based offset in bytes to start | ||
|
@@ -660,9 +660,13 @@ mongooseCommon.GridFSBucket.prototype.readFile = function readFile(optns, done) | |
* bucket.deleteFile(_id, (error, results) => { ... }); | ||
*/ | ||
mongooseCommon.GridFSBucket.prototype.deleteFile = function deleteFile(_id, done) { | ||
this.delete(_id, function afterDelete(error) { | ||
return done(error, _id); | ||
}); | ||
this.delete(_id) | ||
.then(() => { | ||
done(undefined, _id); | ||
}) | ||
.catch((err) => { | ||
done(err, _id); | ||
}); | ||
}; | ||
|
||
mongooseCommon.GridFSBucket.prototype.unlink = mongooseCommon.GridFSBucket.prototype.deleteFile; | ||
|
@@ -836,11 +840,11 @@ mongooseCommon.GridFSBucket.prototype._removeFile = function _removeFile(request | |
* @name createBucket | ||
* @description Create GridFSBucket | ||
* @param {object} [optns] Optional settings. | ||
* @param {object} [optns.connection = mongoose.connection] A valid | ||
* @param {object} [optns.connection] A valid | ||
* instance of mongoose connection. | ||
* @param {string} [optns.bucketName="fs"] The 'files' and 'chunks' collections | ||
* @param {string} [optns.bucketName] The 'files' and 'chunks' collections | ||
* will be prefixed with the bucket name followed by a dot. | ||
* @param {number} [optns.chunkSizeBytes=255 * 1024] Number of bytes stored in | ||
* @param {number} [optns.chunkSizeBytes] Number of bytes stored in | ||
* each chunk. Defaults to 255KB | ||
* @param {object} [optns.writeConcern] Optional write concern to be passed to | ||
* write operations, for instance `{ w: 1 }` | ||
|
@@ -881,13 +885,13 @@ function createBucket(optns = {}) { | |
* @name createModel | ||
* @description Create GridFSBucket files collection model | ||
* @param {object} [optns] Optional settings. | ||
* @param {object} [optns.connection = mongoose.connection] A valid instance | ||
* @param {object} [optns.connection] A valid instance | ||
* of mongoose connection. | ||
* @param {string} [optns.modelName="File"] Valid model name to use with | ||
* @param {string} [optns.modelName] Valid model name to use with | ||
* mongoose | ||
* @param {string} [optns.bucketName="fs"] The 'files' and 'chunks' collections | ||
* @param {string} [optns.bucketName] The 'files' and 'chunks' collections | ||
* will be prefixed with the bucket name followed by a dot. | ||
* @param {number} [optns.chunkSizeBytes=255 * 1024] Number of bytes stored in | ||
* @param {number} [optns.chunkSizeBytes] Number of bytes stored in | ||
* each chunk. Defaults to 255KB | ||
* @param {object} [optns.writeConcern] Optional write concern to be passed to | ||
* write operations, for instance `{ w: 1 }` | ||
|
Oops, something went wrong.