Skip to content

Commit

Permalink
Initial version for lenne.Tech projects
Browse files Browse the repository at this point in the history
  • Loading branch information
kaihaase committed Oct 20, 2023
1 parent 4e72baf commit 5fcf414
Show file tree
Hide file tree
Showing 9 changed files with 2,707 additions and 13,049 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/build.yml
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: .
42 changes: 42 additions & 0 deletions .github/workflows/publish.yml
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 }}
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
# mongoose-gridfs

[![Build Status](https://app.travis-ci.com/lykmapipo/mongoose-gridfs.svg?branch=master)](https://app.travis-ci.com/lykmapipo/mongoose-gridfs)
[![Dependencies Status](https://david-dm.org/lykmapipo/mongoose-gridfs.svg)](https://david-dm.org/lykmapipo/mongoose-gridfs)
[![Coverage Status](https://coveralls.io/repos/github/lykmapipo/mongoose-gridfs/badge.svg?branch=master)](https://coveralls.io/github/lykmapipo/mongoose-gridfs?branch=master)
[![GitHub License](https://img.shields.io/github/license/lykmapipo/mongoose-gridfs)](https://github.com/lykmapipo/mongoose-gridfs/blob/master/LICENSE)

[![Commitizen Friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![Code Style](https://badgen.net/badge/code%20style/airbnb/ff5a5f?icon=airbnb)](https://github.com/airbnb/javascript)
[![npm version](https://img.shields.io/npm/v/mongoose-gridfs)](https://www.npmjs.com/package/mongoose-gridfs)
Forked from https://github.com/hermesdj/mongoose-gridfs
(which is forked from https://github.com/lykmapipo/mongoose-gridfs)
to get a runnable version that works with Mongoose >= 6.

mongoose [gridfs](https://docs.mongodb.com/manual/core/gridfs/) on top of [new gridfs api](http://mongodb.github.io/node-mongodb-native/3.1/tutorials/gridfs/)

Expand Down
34 changes: 19 additions & 15 deletions es/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 }`
Expand Down Expand Up @@ -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 }`
Expand Down
34 changes: 19 additions & 15 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 }`
Expand Down Expand Up @@ -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 }`
Expand Down
Loading

0 comments on commit 5fcf414

Please sign in to comment.