パッケージの詳細

mongoose-gridfs

lykmapipo18.4kMIT1.3.0
mongoose-plugin, mongoose, mongodb, gridfs

readme

mongoose-gridfs

Build Status Dependencies Status Coverage Status GitHub License

Commitizen Friendly code style: prettier Code Style npm version

mongoose gridfs on top of new gridfs api

Note!: Only compatible with Mongoose >= 6.0.7+

Note!: Ensure mongoose connection before use

Requirements

Installation

$ npm install --save mongoose mongoose-gridfs

Usage

import { createReadStream } from 'fs';
import { createModel } from 'mongoose-gridfs';

// use default bucket
const Attachment = createModel();

// or create custom bucket with custom options
const Attachment = createModel({
    modelName: 'Attachment',
    connection: connection
});

// write file to gridfs
const readStream = createReadStream('sample.txt');
const options = ({ filename: 'sample.txt', contentType: 'text/plain' });
Attachment.write(options, readStream, (error, file) => {
  //=> {_id: ..., filename: ..., ...}
});

// read larger file
const readStream = Attachment.read({ _id });

// read smaller file
Attachment.read({ _id }, (error, buffer) => { ... });

// remove file and its content
Attachment.unlink({ _id }, (error) => { ... });

Read Documentation

Literature Reviewed

Testing

  • Clone this repository

  • Install all development dependencies

npm install
  • Run example
npm run dev
  • Then run test
npm test

Contribute

It will be nice, if you open an issue first so that we can know what is going on, then, fork this repo and push in your ideas. Do not forget to add a bit of test(s) of what value you adding.

License

The MIT License (MIT)

Copyright (c) CodeTanzania & Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

更新履歴

1.3.0 (2021-09-27)

Chores
  • release: compile latest source (d0883a73)
  • deps:
    • sync remote updates (9fcb0d2e)
    • bump bl from 2.2.0 to 2.2.1 (1bbcc1b9)
    • bump dot-prop from 4.2.0 to 4.2.1 (f829bc67)
    • bump ini from 1.3.5 to 1.3.7 (e988db60)
    • bump websocket-extensions from 0.1.3 to 0.1.4 (2a30941a)
Other Changes
Refactors

1.2.48 (2020-08-08)

Chores
  • deps: force latest version & audit fix (4e6c051e)

1.2.47 (2020-07-29)

Chores
  • deps: force latest version & audit fix (77ae882c)

1.2.46 (2020-07-14)

Chores
  • deps: force latest version & audit fix (0fc08b42)

1.2.45 (2020-07-02)

Chores
  • deps: force latest version & audit fix (e01a5738)

1.2.44 (2020-06-26)

Chores
  • deps: force latest version & audit fix (ee3b3bcf)

1.2.43 (2020-06-10)

Chores
  • deps: force latest version & audit fix (9dcb35f5)

1.2.42 (2020-05-20)

Chores
  • deps: force latest version & audit fix (741b99a4)

1.2.41 (2020-05-09)

Chores
  • deps: force latest version & audit fix (cedb0592)

1.2.40 (2020-05-02)

1.2.39 (2020-05-02)

Chores
  • deps: force latest version & audit fix (d9c7c055)

1.2.38 (2020-04-27)

1.2.37 (2020-04-27)

Chores
  • deps: force latest version & audit fix (f8a19e89)

1.2.36 (2020-04-16)

1.2.35 (2020-04-16)

Chores
  • deps: force latest version & audit fix (dcccb6f4)

1.2.34 (2020-03-30)

1.2.33 (2020-03-30)

Chores
  • deps: force latest version & audit fix (04c33ad7)

1.2.32 (2020-03-06)

1.2.31 (2020-03-06)

Chores
  • deps: force latest version & audit fix (f6f11270)

1.2.30 (2020-02-28)

1.2.29 (2020-02-28)

Chores
  • deps: force latest version & audit fix (2da2619e)

1.2.28 (2020-02-16)

1.2.27 (2020-02-16)

Chores
  • deps: force latest version & audit fix (92c05713)

1.2.26 (2020-02-04)

1.2.25 (2020-02-04)

Chores
  • deps: force latest version & audit fix (53859e9f)

1.2.24 (2020-01-23)

1.2.23 (2020-01-23)

Chores
  • deps: force latest version & audit fix (4dd8a8a5)

1.2.22 (2020-01-22)

1.2.21 (2020-01-22)

Chores
  • deps: force latest version & audit fix (f576d2c3)

1.2.20 (2020-01-17)

1.2.19 (2020-01-17)

Chores
  • deps: force latest version & audit fix (affddfe0)

1.2.18 (2020-01-14)

1.2.17 (2020-01-14)

Chores
  • deps: force latest version & audit fix (e99f2d12)

1.2.16 (2020-01-12)

1.2.15 (2020-01-12)

Chores
  • deps: force latest version & audit fix (a8da3eea)

1.2.14 (2019-11-14)

Chores
  • deps: force latest version & audit fix (00cd8aa7)

1.2.13 (2019-10-23)

Chores
  • deps: force latest version & audit fix (cbb6b8fa)

1.2.12 (2019-10-10)

Chores
  • deps: force latest version & audit fix (bf1c5c3c)

1.2.11 (2019-10-08)

Chores
  • deps: force latest version & audit fix (5ff4c114)

1.2.10 (2019-10-07)

Chores
  • deps:
    • force latest version & audit fix (df87437d)
    • force latest version & audit fix (4e7d536f)

1.2.9 (2019-09-28)

Chores
  • deps: force latest version & audit fix (349405d4)

1.2.8 (2019-09-26)

Chores
  • deps: force latest version & audit fix (b752b1bb)

1.2.7 (2019-09-18)

Chores
  • deps: force latest version & audit fix (d3fa6175)
Documentation Changes

1.2.6 (2019-09-16)

Chores
  • deps: force latest version & audit fix (16c49e65)

1.2.5 (2019-08-14)

Chores
  • deps: force latest version & audit fix (286584c7)

1.2.4 (2019-07-09)

Chores
  • deps: force latest version & audit fix (d8029a61)

1.2.3 (2019-06-19)

Chores
  • deps: force latest version & audit fix (3e397d21)

1.2.2 (2019-06-12)

Chores
  • deps: force latest version & audit fix (f1f2b516)
Refactors
  • bucket: remove exist connection check to allow lazy connections (8e1ed2ff)

1.2.1 (2019-06-09)

Chores
  • deps: force latest version & audit fix (26952c05)

1.2.0 (2019-06-04)

New Features

1.1.1 (2019-06-04)

Chores
  • deps: force latest version & audit fix (3a414e9a)

1.1.0 (2019-06-02)

New Features
  • add timestamps virtuals and expose on toJSON and toObject (7e58c150)
  • allow plugins on createModel (95cec963)
Tests
  • implement metadata getById, put, patch for rest actions (0bf51e7c)
  • implement search rest actions test (d3321ad7)
  • implement rest actions tests (08b436f3)

1.0.7 (2019-06-02)

Chores
  • deps: force latest version & audit fix (58074825)

1.0.6 (2019-05-31)

Chores
  • deps: force latest version & audit fix (f77872a9)

1.0.5 (2019-05-25)

Documentation Changes
  • remove year on license and fix typos (a79882eb)
Refactors
  • schema: rename createSchema to createFileSchema (88e74fcd)
Tests
  • removing underscores on variables (bae3e7ed)

1.0.4 (2019-05-25)

Chores
  • deps: force latest version & audit fix (20beb5ec)

1.0.3 (2019-05-20)

Chores
  • deps: force latest version & audit fix (00355bc3)

1.0.2 (2019-05-12)

Chores
  • deps: force latest version & audit fix (01bcd103)

1.0.1 (2019-05-01)

Chores
  • ci: force latest nodejs (a00e135d)
  • .npmrc: prevent npm version to commit and tag version (f159d18b)
  • deps: force latest version & audit fix (2c23c325)

1.0.0 (2019-04-27)

Chores
  • ci:
    • revert to mongodb-3.4-precise in travis (4d5572d7)
    • force mongodb-4.0-xenial in travis (c00c2545)
    • force latest nodejs on travis (0988d243)
  • scripts: add documentation generator (be12d5e2)
  • dependencies: force latest versions (7dbfa83c)
Documentation Changes
  • add code of conduct and contributing guide (ac00d466)
  • re-organize usage docs (3b1d4fc7)
  • update usage docs (9084db17)
  • api: generate and link api documentation (b002db6f)
Refactors
  • lint: update lint & fix sources (8fed534a)
Code Style Changes