Registry / database / gridfile

gridfile

JSON →
library1.1.6jsnpmunverified

GridFile is a reusable Mongoose schema for MongoDB GridFS, enabling file upload/download directly through your Mongoose connection without separate GridFS setup. Current stable version is 1.1.6. It integrates with Mongoose models and supports streaming uploads and downloads. Differentiator: provides a clean Mongoose-based API for GridFS operations, unlike lower-level drivers or separate libraries.

npm install gridfile
INSTALL
IMPORT
SIG · GRIDFILE
G
gridfile
databasejavascriptv1.1.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

schema
const schema = require('gridfile')
import schema from 'gridfile'
Package uses default CommonJS export; in ESM use: import schema from 'gridfile' (works with 'default')
default
import schema from 'gridfile'
import { schema } from 'gridfile'
Named import does not exist; the module exports a single schema object as default

Demonstrates connecting to MongoDB, creating a GridFile model, uploading a file stream, and downloading by ID.

const mongoose = require('mongoose'); const schema = require('gridfile'); mongoose.connect('mongodb://localhost:27017/test'); const GridFile = mongoose.model('GridFile', schema); const gridFile = new GridFile(); gridFile.filename = 'test.txt'; gridFile.metadata = { user: 'alice' }; const stream = fs.createReadStream('test.txt'); await gridFile.upload(stream); const id = gridFile._id; const found = await GridFile.findById(id); const downloadStream = fs.createWriteStream('downloaded.txt'); await found.download(downloadStream);
Debug
Known issues
deprecatedThe schema method 'upload' may change in future versions; use with caution.
fix
Check documentation for any migration guide before upgrading.
affects: <=1.1.6
Errors
Common errors & fixes
Error: The schema is not registered on the model.
Missing mongoose connection before creating model.
fix
Ensure mongoose.connect() is called before mongoose.model()
Upgrade
Version history
1.1.6latest on npm
Audit
Dependencies
mongooserequiredpeer dependency; GridFile requires Mongoose to interact with MongoDB GridFS
Agent activity
6 hits · last 30 days
node
6
Resources
gridfile — npm install gridfile · libregistry