,
line 93Create a new GridStore instance
Modes
db
Db
A database instance to interact with.
id
object optional
optional unique id for this file
filename
string optional
optional filename for this file, no unique constrain on the field
mode
string
set the mode for this file.
options
object optional
Optional settings.
Name Type Default Descriptionw
number | string optional
Deprecated The write concern. Use writeConcern instead.
wtimeout
number optional
Deprecated The write concern timeout. Use writeConcern instead.
j
boolean false optional
Deprecated Specify a journal write concern. Use writeConcern instead.
fsync
boolean false optional
Deprecated Specify a file sync write concern. Use writeConcern instead.
writeConcern
object | WriteConcern optional
Specify write concern settings.
root
string optional
Root collection to use. Defaults to {GridStore.DEFAULT_ROOT_COLLECTION}.
content_type
string optional
MIME type of the file. Defaults to {GridStore.DEFAULT_CONTENT_TYPE}.
chunk_size
number 261120 optional
Size for the chunk. Defaults to {Chunk.DEFAULT_CHUNK_SIZE}.
metadata
object optional
Arbitrary data the user wants to store.
promiseLibrary
object optional
A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible
readPreference
ReadPreference | string optional
The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
chunkSize
number
Get the gridstore chunk size.
md5
number
The md5 checksum for this file.
chunkNumber
number
The current chunk number the gridstore has materialized into memory
Default file mime type
The collection to be used for holding the files and chunks collection.
Seek mode where the given length is an offset to the current read/write head.
Seek mode where the given length is an offset to the end of the file.
Seek mode where the given length is absolute.
,
line 1296Checks if a file exists in the database.
Name Type Descriptiondb
Db
the database to query.
name
string
The name of the file to look for.
rootCollection
string optional
The root collection that holds the files and chunks collection. Defaults to {GridStore.DEFAULT_ROOT_COLLECTION}.
options
object optional
Optional settings.
Name Type DescriptionreadPreference
ReadPreference | string optional
The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
promiseLibrary
object optional
A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible
session
ClientSession optional
optional session to use for this operation
callback
GridStore~resultCallback optional
result from exists.
,
line 1359Gets the list of files stored in the GridFS.
Name Type Descriptiondb
Db
the database to query.
rootCollection
string optional
The root collection that holds the files and chunks collection. Defaults to {GridStore.DEFAULT_ROOT_COLLECTION}.
options
object optional
Optional settings.
Name Type DescriptionreadPreference
ReadPreference | string optional
The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
promiseLibrary
object optional
A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible
session
ClientSession optional
optional session to use for this operation
callback
GridStore~resultCallback optional
result from exists.
,
line 1427Reads the contents of a file.
This method has the following signatures
(db, name, callback)
(db, name, length, callback)
(db, name, length, offset, callback)
(db, name, length, offset, options, callback)
db
Db
the database to query.
name
string
The name of the file.
length
number optional
The size of data to read.
offset
number optional
The offset from the head of the file of which to start reading from.
options
object optional
Optional settings.
Name Type DescriptionreadPreference
ReadPreference | string optional
The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
promiseLibrary
object optional
A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible
session
ClientSession optional
optional session to use for this operation
callback
GridStore~readCallback optional
the command callback.
,
line 1481Read the entire file as a list of strings splitting by the provided separator.
Name Type Descriptiondb
Db
the database to query.
name
String | object
the name of the file.
separator
string optional
The character to be recognized as the newline separator.
options
object optional
Optional settings.
Name Type DescriptionreadPreference
ReadPreference | string optional
The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
promiseLibrary
object optional
A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible
session
ClientSession optional
optional session to use for this operation
callback
GridStore~readlinesCallback optional
the command callback.
,
line 1518Deletes the chunks and metadata information of a file from GridFS.
Name Type Descriptiondb
Db
The database to query.
names
string | array
The name/names of the files to delete.
options
object optional
Optional settings.
Name Type DescriptionpromiseLibrary
object optional
A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible
session
ClientSession optional
optional session to use for this operation
callback
GridStore~resultCallback optional
the command callback.
,
line 569Retrieve this file's chunks collection.
Name Type Descriptioncallback
GridStore~collectionCallback
the command callback.
,
line 481Saves this file to the database. This will overwrite the old entry if it
already exists. This will work properly only if mode was initialized to
"w" or "w+".
options
object optional
Optional settings
Name Type Descriptionsession
ClientSession optional
optional session to use for this operation
callback
GridStore~resultCallback optional
this will be called after executing this method. The first parameter will contain null and the second one will contain a reference to this object.
,
line 621Retrieves the file collection associated with this object.
Name Type Descriptioncallback
GridStore~collectionCallback
the command callback.
,
line 374Handles the destroy part of a stream
,
line 262Verify if the file is at EOF.
,
line 283Retrieves a single character from this file.
Name Type Descriptioncallback
GridStore~resultCallback optional
this gets called after this method is executed. Passes null to the first parameter and the character read to the second or null to the second if the read/write head is at the end of the file.
,
line 200Opens the file from the database and initialize this object. Also creates a
new one if file does not exist.
options
object optional
Optional settings
Name Type Descriptionsession
ClientSession optional
optional session to use for this operation
callback
GridStore~openCallback optional
this will be called after executing this method
,
line 319Writes a string to the file with a newline character appended at the end if
the given string does not have one.
string
string
the string to write.
options
object optional
Optional settings
Name Type Descriptionsession
ClientSession optional
optional session to use for this operation
callback
GridStore~resultCallback optional
this will be called after executing this method. The first parameter will contain null and the second one will contain a reference to this object.
,
line 743Retrieves the contents of this file and advances the read/write head. Works with Buffers only.
There are 3 signatures for this method:
(callback)
(length, callback)
(length, buffer, callback)
length
number optional
the number of characters to read. Reads all the characters from the read/write head to the EOF if not specified.
buffer
string | Buffer optional
a string to hold temporary data. This is used for storing the string data read so far when recursively calling this method.
options
object optional
Optional settings
Name Type Descriptionsession
ClientSession optional
optional session to use for this operation
callback
GridStore~readCallback optional
the command callback.
,
line 644Read the entire file as a list of strings splitting by the provided separator.
Name Type Descriptionseparator
string optional
The character to be recognized as the newline separator.
options
object optional
Optional settings
Name Type Descriptionsession
ClientSession optional
optional session to use for this operation
callback
GridStore~readlinesCallback optional
the command callback.
,
line 684Deletes all the chunks of this file in the database if mode was set to "w" or
"w+" and resets the read/write head to the initial position.
options
object optional
Optional settings
Name Type Descriptionsession
ClientSession optional
optional session to use for this operation
callback
GridStore~resultCallback optional
this will be called after executing this method. The first parameter will contain null and the second one will contain a reference to this object.
,
line 863Moves the read/write head to a new location.
There are 3 signatures for this method
Seek Location Modes
position
number optional
the position to seek to
seekLocation
number optional
seek mode. Use one of the Seek Location modes.
options
object optional
Optional settings
Name Type Descriptionsession
ClientSession optional
optional session to use for this operation
callback
GridStore~gridStoreCallback optional
the command callback.
,
line 339Return a modified Readable stream including a possible transform method.
,
line 827Retrieves the position of the read/write head of this file.
Name Type Descriptionlength
number optional
the number of characters to read. Reads all the characters from the read/write head to the EOF if not specified.
buffer
string | Buffer optional
a string to hold temporary data. This is used for storing the string data read so far when recursively calling this method.
options
object optional
Optional settings
Name Type Descriptionsession
ClientSession optional
optional session to use for this operation
callback
GridStore~tellCallback optional
the command callback.
,
line 584Deletes all the chunks of this file in the database.
Name Type Descriptionoptions
object optional
Optional settings
Name Type Descriptionsession
ClientSession optional
optional session to use for this operation
callback
GridStore~resultCallback optional
the command callback.
,
line 355Writes some data. This method will work properly only if initialized with mode "w" or "w+".
Name Type Descriptiondata
string | Buffer
the data to write.
close
boolean optional
closes this file after writing if set to true.
options
object optional
Optional settings
Name Type Descriptionsession
ClientSession optional
optional session to use for this operation
callback
GridStore~resultCallback optional
this will be called after executing this method. The first parameter will contain null and the second one will contain a reference to this object.
,
line 396Stores a file from the file system to the GridFS database.
Name Type Descriptionfile
string | Buffer | FileHandle
the file to store.
options
object optional
Optional settings
Name Type Descriptionsession
ClientSession optional
optional session to use for this operation
callback
GridStore~resultCallback optional
this will be called after executing this method. The first parameter will contain null and the second one will contain a reference to this object.
,
line 554The collection callback format.
Name Type Descriptionerror
MongoError
An error instance representing the error during the execution.
collection
Collection
The collection from the command execution.
,
line 837The tell callback format.
Name Type Descriptionerror
MongoError
An error instance representing the error during the execution.
gridStore
GridStore
The gridStore.
,
line 182The callback format for the Gridstore.open method
Name Type Descriptionerror
MongoError
An error instance representing the error during the execution.
gridStore
GridStore
The GridStore instance if the open method was successful.
,
line 718The read callback format.
Name Type Descriptionerror
MongoError
An error instance representing the error during the execution.
data
Buffer
The data read from the GridStore object
,
line 626The readlines callback format.
Name Type Descriptionerror
MongoError
An error instance representing the error during the execution.
strings
Array.<string>
The array of strings returned.
,
line 266The callback result format.
Name Type Descriptionoptions
object optional
Optional settings
Name Type Descriptionsession
ClientSession optional
optional session to use for this operation
error
MongoError
An error instance representing the error during the execution.
result
object
The result from the callback.
,
line 808The tell callback format.
Name Type Descriptionerror
MongoError
An error instance representing the error during the execution.
position
number
The current read position in the GridStore.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4