utils.GridSQL Class
MongoDB's GridFS inspired data storage for Knex. The given file is saved to multiple binary columns in order to enable proper file streaming.
GridSQL works like a key value store. All files must be written with an unique file id.
Constructor
utils.GridSQL
(
-
options
Parameters:
-
optionsObject-
knexObjectKnex instance
-
[chunkSize=(1024*255)]Object optionalChunk size
-
[tableName=chunks]Object optionalTable name
-
Methods
read
(
stream.Readable
-
fileId
Read file as a node.js readable stream.
This method has a little bug https://github.com/tgriesser/knex/issues/484
Parameters:
-
fileIdString
Returns:
stream.Readable:
write
(
Bluebird.Promise
-
fileId -
readable -
[options]
Write node.js readable stream database with a unique file id
Parameters:
-
fileIdString -
readablestream.Writable -
[options]Object optional-
[chunkSize]Object optionalCustom chunks size for this file
-
Returns:
Bluebird.Promise:
The returned promise is resolved when the readable stream is fully saved to the database
