Sequelize File
This package allows you to attach files to your sequelize instances as easy as you set your plain attributes and define MIME type validation and post-processing rules next to your models.
Requirements
- ImageMagick (
brew install imagemagick
on OS X).
Usage
First, you define which fileds you want to enhance with attachments logic:
/* models/attachments.js */ ; const picture = ; const backgroundImage = ;
Then, you attach enhanced attributes to your model:
/* models/User.js */ ;;; let User = sequelize; picture;backgroundImage; ;
After this, you'll be able to set files just as ordinary sequelize attributes. You can attach files either as urls (they will be downloaded), or as pre-downloaded multer-style objects (basically, only path
and mimetype
props are required)
sequelize;
You access all of your resized images through dot notation. If you didn't setup resizing, you'll get a string path to attached file.
User;
Status
This package is under early development. Do use it with caution! Check out tests to see what is currently working.