1.0.7 • Published 3 years ago

json-gridfsbucket v1.0.7

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

json Object to GridFSBucket

Directly JSON Object to GridFSBucket. This package converts JSON object to streamable stringify, then pipe to GridFSBucket.

npm i json-gridfsbucket
import { connect } from 'mongoose';
import { uploadGridFSBucket, downloadGridFSBucket } from "json-gridfsbucket"


const _json = {
    foo: "bar",
    very_big_key_of_value: "VERY_BIG_VALUE"
}

const run = async () => {
    const options = {
        user: "root",
        pass: "example",
        dbName: "test"
    }
    
    const mongoose = await connect('mongodb://localhost:27017', options);
    
    const bucketOptions = {
        mongoose, bucketName: "bucket1", filename: "file.json"
    }

    const _resUpload = await uploadGridFSBucket(_json, bucketOptions)
    console.log("res of upload:", _resUpload)
    /**
     *       {
     *          bucketName: "bucket1",
     *          filename: "file.json"
     *       }
    */

    const _resDownload = await downloadGridFSBucket(bucketOptions)
    console.log("res of download:", _resDownload)
    /**
     *      {
     *          foo: "bar",
     *          very_big_key_of_value: "VERY_BIG_VALUE"
     *      }
     */
}

run()
1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago