Mongo.GridFs.Bucket (Mongodb v1.0.0) View Source
The bucket has some configuration options:
:chunk_size
- The chunk size in bytes. Defaults to255*1024
:name
- The bucket name. Defaults tofs
The bucket checks whether the indexes already exist before attempting to create them. The names of the created indexes are "filename_1_uploadDate_1" and "files_id_1_n_1"
Link to this section Summary
Functions
Returns the collection name for the chunks collection, default is fs.chunks.
Given a id
, delete this stored file’s files collection document and
associated chunks from a GridFS bucket.
Drops the files and chunks collections associated with this bucket.
Returns the collection name for the files collection, default is fs.files.
Returns a cursor from the fs.files collection.
Finds one file document with the file_id as a string or as an ObjectID-struct
Creates a new Bucket with a existing connection using the default values. It just contains the name of the collections (fs) and the chunk size (255KB).
Renames the stored file with the specified file_id.
Link to this section Types
Specs
t() :: %Mongo.GridFs.Bucket{ chunk_size: non_neg_integer(), name: String.t(), opts: term(), topology_pid: GenServer.server() }
Link to this section Functions
Specs
Returns the collection name for the chunks collection, default is fs.chunks.
Specs
delete(t(), String.t()) :: {:ok, %Mongo.DeleteResult{acknowledged: term(), deleted_count: term()}}
delete(t(), BSON.ObjectId.t()) :: {:ok, %Mongo.DeleteResult{acknowledged: term(), deleted_count: term()}}
Given a id
, delete this stored file’s files collection document and
associated chunks from a GridFS bucket.
Specs
drop(t()) :: Mongo.result(BSON.document())
Drops the files and chunks collections associated with this bucket.
Specs
Returns the collection name for the files collection, default is fs.files.
Specs
find(t(), BSON.document(), Keyword.t()) :: Mongo.cursor()
Returns a cursor from the fs.files collection.
Specs
find_one(t(), String.t()) :: BSON.document() | nil
find_one(t(), BSON.ObjectId.t()) :: BSON.document() | nil
Finds one file document with the file_id as a string or as an ObjectID-struct
Specs
new(GenServer.server(), Keyword.t()) :: t()
Creates a new Bucket with a existing connection using the default values. It just contains the name of the collections (fs) and the chunk size (255KB).
The bucket checks the index for both collections as well. In case of multiple upload or downloads just create only one bucket and reuse it.
Specs
rename(t(), BSON.ObjectId.t(), String.t()) :: Mongo.result(BSON.document())
Renames the stored file with the specified file_id.