1.2.0 • Published 4 months ago

sequelize-db-storage-files v1.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
4 months ago

Database file storage

Install

npm i sequelize-db-storage-files

Initialization

import { DbStorageFiles } from "sequelize-db-storage-files";
import { Sequelize } from "sequelize-typescript";

const sequelize = new Sequelize({
        // ... options
});
    
const dbStorageFiles = new DbStorageFiles(sequelize);
await sequelize.sync();

Create File

const file = await dbStorageFiles.write('/text.txt', Buffer.from('Hello, World!'));

Get File

const file = await dbStorageFiles.getFromPath('/text.txt');
if(!file) throw new Error("Not found File");
const text = (await file.getFileData()).data.toString('utf-8'); 
console.log(text); // Hello, World!

File Info

file.id // string(uuidv4)
file.z // string
file.hash // string (sha256)
file.info // string (json)
file.size // number (bytes)
file.deletionDate // Date | null
file.createdAt // Date
file.updatedAt // Date

DbStorageFile and DbStorageFileData are sequelize models, so all the methods in the sequelize documentation apply to them

1.2.0

4 months ago

1.1.1

7 months ago

1.1.0

7 months ago

1.1.9

5 months ago

1.1.8

7 months ago

1.1.7

7 months ago

1.1.6

7 months ago

1.1.5

7 months ago

1.0.6

8 months ago

1.1.4

7 months ago

1.0.5

8 months ago

1.1.3

7 months ago

1.1.2

7 months ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago