mongo.gridfs.find: Find a GridFS file

Description Usage Arguments Value See Also Examples

View source: R/gridfs.R

Description

Find a GridFS file and return a mongo.gridfile object used for further operations on it

Usage

1
mongo.gridfs.find(gridfs, query)

Arguments

gridfs

A (mongo.gridfs) object.

query

(string) The name of the GridFS file to locate.

This parameter may also be a mongo.bson query object and is used to search the GridFS "files" collection documents for matches. Alternately, query may be a list which will be converted to a mongo.bson object by mongo.bson.from.list().

Value

NULL, if not found; otherwise, a mongo.gridfile object corresponding to the found GridFS file.

See Also

mongo.gridfile,
mongo.gridfile.get.filename,
mongo.gridfs.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
mongo <- mongo.create()
if (mongo.is.connected(mongo)) {
    gridfs <- mongo.gridfs.create(mongo, "grid")

    gf <- mongo.gridfs.find(gridfs, "test.dat")
    print(mongo.gridfile.get.length(gf))

    # find a GridFS file uploaded midnight July 4, 2008
    buf <- mongo.bson.buffer.create()
    mongo.bson.buffer.append(buf, "uploadDate",
        strptime("07-04-2008", "%m-%d-%Y"))
    query <- mongo.bson.from.buffer(buf)
    gf <- mongo.gridfs.find(gridfs, query)

    if (!is.null(gf))
        print(mongo.gridfile.get.filename(gf))

    mongo.gridfs.destroy(gridfs)
}

jonkatz2/rmongodb documentation built on May 19, 2019, 7:30 p.m.