├── .Rbuildignore ├── data └── zips.rda ├── vignettes └── mongosoup.png ├── demo └── 00Index ├── src ├── helpers.h ├── libmongo │ ├── README.md │ ├── env.h │ └── encoding.h ├── Makevars.win ├── Makevars ├── helpers.c ├── utility.h ├── symbols.h ├── api_gridfs.h └── symbols.c ├── tests ├── test_cursor.R ├── test_bson_iterator.R ├── test_errors.R ├── test_indices.R ├── test_update.R └── test_bson_from.R ├── R ├── rmongodb_imports.R ├── zzz.R └── utils.R ├── man ├── mongo.find.exhaust.Rd ├── mongo.find.slave.ok.Rd ├── mongo.index.sparse.Rd ├── mongo.find.await.data.Rd ├── mongo.find.oplog.replay.Rd ├── mongo.index.background.Rd ├── mongo.index.unique.Rd ├── mongo.find.cursor.tailable.Rd ├── mongo.find.partial.results.Rd ├── mongo.index.drop.dups.Rd ├── mongo.find.no.cursor.timeout.Rd ├── mongo.binary.md5.Rd ├── mongo.binary.uuid.Rd ├── mongo.binary.user.Rd ├── mongo.binary.old.Rd ├── mongo.binary.function.Rd ├── mongo.binary.binary.Rd ├── mongo.update.basic.Rd ├── mongo.update.upsert.Rd ├── mongo.update.multi.Rd ├── mongo.reconnect.Rd ├── mongo.bson.date.Rd ├── mongo.bson.null.Rd ├── mongo.bson.oid.Rd ├── mongo.bson.code.Rd ├── mongo.bson.double.Rd ├── mongo.bson.int.Rd ├── mongo.bson.string.Rd ├── mongo.bson.symbol.Rd ├── mongo.get.socket.Rd ├── mongo.bson.eoo.Rd ├── mongo.bson.object.Rd ├── mongo.bson.long.Rd ├── mongo.bson.regex.Rd ├── mongo.bson.undefined.Rd ├── mongo.bson.bool.Rd ├── mongo.bson.timestamp.Rd ├── mongo.bson.binary.Rd ├── mongo.bson.buffer.create.Rd ├── mongo.bson.array.Rd ├── mongo.bson.code.w.scope.Rd ├── mongo.bson.destroy.Rd ├── mongo.get.primary.Rd ├── mongo.is.connected.Rd ├── mongo.get.timeout.Rd ├── mongo.bson.from.JSON.Rd ├── mongo.get.hosts.Rd ├── mongo.oid.print.Rd ├── mongo.get.databases.Rd ├── zips.Rd ├── mongo.bson.size.Rd ├── mongo.disconnect.Rd ├── mongo.gridfs.remove.file.Rd ├── mongo.bson.print.Rd ├── mongo.bson.empty.Rd ├── mongo.oid.time.Rd ├── mongo.drop.Rd ├── mongo.shorthand.Rd ├── mongo.bson.buffer.append.null.Rd ├── mongo.gridfs.destroy.Rd ├── mongo.set.timeout.Rd ├── mongo.drop.database.Rd ├── mongo.add.user.Rd ├── mongo.bson.buffer.append.oid.Rd ├── mongo.is.master.Rd ├── print.mongo.oid.Rd ├── mongo.bson.dbref.Rd ├── mongo.rename.Rd ├── print.mongo.bson.Rd ├── mongo.bson.iterator.Rd ├── mongo.bson.buffer.size.Rd ├── mongo.bson.from.buffer.Rd ├── mongo.authenticate.Rd ├── mongo.destroy.Rd ├── mongo.bson.from.df.Rd ├── mongo.gridfile.destroy.Rd ├── mongo.undefined.create.Rd ├── mongo.bson.buffer.append.regex.Rd ├── mongo.get.database.collections.Rd ├── mongo.regex.Rd ├── mongo.oid.create.Rd ├── mongo.distinct.Rd ├── mongo.oid.to.string.Rd ├── mongo.oid.from.string.Rd ├── mongo.code.create.Rd ├── as.character.mongo.oid.Rd ├── mongo.bson.buffer.append.list.Rd ├── mongo.symbol.create.Rd ├── mongo.bson.buffer.append.timestamp.Rd ├── mongo.regex.create.Rd ├── mongo.cursor.next.Rd ├── mongo.cursor.value.Rd ├── mongo.bson.iterator.key.Rd ├── mongo.gridfile.writer.finish.Rd ├── mongo.gridfs.store.file.Rd ├── mongo.oid.Rd ├── mongo.symbol.Rd ├── mongo.code.w.scope.create.Rd ├── mongo.undefined.Rd ├── mongo.bson.buffer.Rd ├── mongo.bson.buffer.append.undefined.Rd ├── mongo.bson.Rd ├── mongo.bson.find.Rd ├── mongo.bson.buffer.append.code.Rd ├── mongo.Rd ├── mongo.code.Rd ├── mongo.bson.buffer.append.bson.Rd ├── mongo.get.err.Rd ├── mongo.gridfs.create.Rd ├── mongo.insert.Rd ├── mongo.cursor.to.data.frame.Rd ├── mongo.simple.command.Rd ├── mongo.bson.buffer.finish.object.Rd ├── mongo.gridfile.get.length.Rd ├── mongo.bson.buffer.append.element.Rd ├── mongo.cursor.to.list.Rd ├── mongo.gridfile.get.md5.Rd ├── mongo.cursor.Rd ├── mongo.bson.buffer.append.symbol.Rd ├── mongo.gridfile.get.upload.date.Rd ├── mongo.gridfile.get.chunk.size.Rd ├── mongo.bson.to.list.Rd ├── mongo.gridfs.find.Rd ├── mongo.get.server.err.Rd ├── mongo.timestamp.Rd ├── mongo.get.server.err.string.Rd ├── mongo.gridfile.get.chunk.count.Rd ├── mongo.bson.buffer.append.time.Rd ├── mongo.reset.err.Rd ├── mongo.gridfile.get.content.type.Rd ├── mongo.gridfile.writer.write.Rd ├── mongo.bson.buffer.start.object.Rd ├── mongo.gridfile.writer.create.Rd ├── mongo.timestamp.create.Rd ├── mongo.gridfile.pipe.Rd ├── mongo.gridfs.store.Rd ├── mongo.gridfile.get.descriptor.Rd ├── mongo.gridfile.seek.Rd ├── mongo.gridfile.get.filename.Rd ├── mongo.gridfile.get.metadata.Rd ├── mongo.remove.Rd ├── mongo.code.w.scope.Rd ├── mongo.cursor.destroy.Rd ├── mongo.insert.batch.Rd ├── mongo.gridfile.writer.Rd ├── mongo.index.TTLcreate.Rd ├── mongo.bson.buffer.append.code.w.scope.Rd ├── mongo.bson.iterator.create.Rd ├── mongo.bson.from.list.Rd ├── mongo.gridfile.Rd ├── mongo.bson.buffer.start.array.Rd └── mongo.bson.buffer.append.raw.Rd ├── rmongodb.Rproj ├── .gitignore └── DESCRIPTION /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | -------------------------------------------------------------------------------- /data/zips.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dselivanov/rmongodb/HEAD/data/zips.rda -------------------------------------------------------------------------------- /vignettes/mongosoup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dselivanov/rmongodb/HEAD/vignettes/mongosoup.png -------------------------------------------------------------------------------- /demo/00Index: -------------------------------------------------------------------------------- 1 | teachers_aid A simplified utility for maintaining a student database with grade curving 2 | -------------------------------------------------------------------------------- /src/helpers.h: -------------------------------------------------------------------------------- 1 | /* Dmitriy Selivanov (2014) https://github.com/dselivanov */ 2 | #include 3 | int* _IS_NA(SEXP x); 4 | -------------------------------------------------------------------------------- /tests/test_cursor.R: -------------------------------------------------------------------------------- 1 | library(rmongodb) 2 | library(RUnit) 3 | 4 | # ? tests 5 | # 22.11.2013 6 | 7 | 8 | #m <- matrix(NA, nrow=2, ncol=4) 9 | 10 | #rbind.nosql 11 | 12 | 13 | -------------------------------------------------------------------------------- /R/rmongodb_imports.R: -------------------------------------------------------------------------------- 1 | #' @useDynLib rmongodb 2 | #' @import jsonlite 3 | #' @import plyr 4 | #' 5 | .onUnload <- function(libpath) 6 | library.dynam.unload("rmongodb", libpath) 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/libmongo/README.md: -------------------------------------------------------------------------------- 1 | MongoDB C Driver 2 | ================================ 3 | 4 | Version: 0.7.1 5 | 6 | URL: https://github.com/mongodb/mongo-c-driver 7 | 8 | Description: Libmongoc is a client library written in C for MongoDB. -------------------------------------------------------------------------------- /src/Makevars.win: -------------------------------------------------------------------------------- 1 | PKG_LIBS = -lws2_32 2 | PKG_CFLAGS += -DMONGO_STATIC_BUILD -DR_SAFETY_NET 3 | 4 | SOURCES = $(wildcard libbson/yajl/*.c libbson/bson/*.c libmongo/*.c *.c) 5 | 6 | OBJECTS = $(SOURCES:.c=.o) 7 | 8 | all: $(SHLIB) 9 | -------------------------------------------------------------------------------- /src/Makevars: -------------------------------------------------------------------------------- 1 | PKG_CFLAGS += -D_MONGO_USE_GETADDRINFO -DR_SAFETY_NET 2 | 3 | SOURCES = $(wildcard libbson/yajl/*.c libbson/bson/*.c libmongo/*.c *.c) 4 | 5 | OBJECTS = $(SOURCES:.c=.o) 6 | 7 | all: clean $(SHLIB) 8 | 9 | clean: 10 | rm -f $(OBJECTS) 11 | -------------------------------------------------------------------------------- /man/mongo.find.exhaust.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.find.exhaust} 4 | \alias{mongo.find.exhaust} 5 | \title{mongo.find flag constant - exhaust} 6 | \format{\preformatted{ int 64 7 | }} 8 | \usage{ 9 | mongo.find.exhaust 10 | } 11 | \value{ 12 | 64L 13 | } 14 | \description{ 15 | \code{\link{mongo.find}()} flag constant - exhaust. 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/mongo.find.slave.ok.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.find.slave.ok} 4 | \alias{mongo.find.slave.ok} 5 | \title{mongo.find flag constant - slave ok} 6 | \format{\preformatted{ int 4 7 | }} 8 | \usage{ 9 | mongo.find.slave.ok 10 | } 11 | \value{ 12 | 4L 13 | } 14 | \description{ 15 | \code{\link{mongo.find}()} flag constant - slave ok. 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/mongo.index.sparse.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.index.sparse} 4 | \alias{mongo.index.sparse} 5 | \title{mongo.index.create flag constant - sparse} 6 | \format{\preformatted{ int 16 7 | }} 8 | \usage{ 9 | mongo.index.sparse 10 | } 11 | \value{ 12 | 16L 13 | } 14 | \description{ 15 | \code{\link{mongo.index.create}()} flag constant - sparse. 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/mongo.find.await.data.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.find.await.data} 4 | \alias{mongo.find.await.data} 5 | \title{mongo.find flag constant - await data} 6 | \format{\preformatted{ int 32 7 | }} 8 | \usage{ 9 | mongo.find.await.data 10 | } 11 | \value{ 12 | 32L 13 | } 14 | \description{ 15 | \code{\link{mongo.find}()} flag constant - await data. 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/mongo.find.oplog.replay.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.find.oplog.replay} 4 | \alias{mongo.find.oplog.replay} 5 | \title{mongo.find flag constant - oplog replay} 6 | \format{\preformatted{ int 8 7 | }} 8 | \usage{ 9 | mongo.find.oplog.replay 10 | } 11 | \value{ 12 | 8L 13 | } 14 | \description{ 15 | \code{\link{mongo.find}()} flag constant - oplog replay. 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/mongo.index.background.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.index.background} 4 | \alias{mongo.index.background} 5 | \title{mongo.index.create flag constant - background} 6 | \format{\preformatted{ int 8 7 | }} 8 | \usage{ 9 | mongo.index.background 10 | } 11 | \value{ 12 | 8L 13 | } 14 | \description{ 15 | \code{\link{mongo.index.create}()} flag constant - background. 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/mongo.index.unique.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.index.unique} 4 | \alias{mongo.index.unique} 5 | \title{mongo.index.create flag constant - unique keys} 6 | \format{\preformatted{ int 1 7 | }} 8 | \usage{ 9 | mongo.index.unique 10 | } 11 | \value{ 12 | 1L 13 | } 14 | \description{ 15 | \code{\link{mongo.index.create}()} flag constant - unique keys (no 16 | duplicates). 17 | } 18 | \keyword{datasets} 19 | 20 | -------------------------------------------------------------------------------- /rmongodb.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageInstallArgs: --no-multiarch --with-keep.source 20 | PackageRoxygenize: rd,collate,namespace 21 | -------------------------------------------------------------------------------- /man/mongo.find.cursor.tailable.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.find.cursor.tailable} 4 | \alias{mongo.find.cursor.tailable} 5 | \title{mongo.find flag constant - cursor tailable} 6 | \format{\preformatted{ int 2 7 | }} 8 | \usage{ 9 | mongo.find.cursor.tailable 10 | } 11 | \value{ 12 | 2L 13 | } 14 | \description{ 15 | \code{\link{mongo.find}()} flag constant - cursor tailable. 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/mongo.find.partial.results.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.find.partial.results} 4 | \alias{mongo.find.partial.results} 5 | \title{mongo.find flag constant - partial results} 6 | \format{\preformatted{ int 128 7 | }} 8 | \usage{ 9 | mongo.find.partial.results 10 | } 11 | \value{ 12 | 128L 13 | } 14 | \description{ 15 | \code{\link{mongo.find}()} flag constant - partial results. 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/mongo.index.drop.dups.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.index.drop.dups} 4 | \alias{mongo.index.drop.dups} 5 | \title{mongo.index.create flag constant - drop duplicate keys} 6 | \format{\preformatted{ int 4 7 | }} 8 | \usage{ 9 | mongo.index.drop.dups 10 | } 11 | \value{ 12 | 4L 13 | } 14 | \description{ 15 | \code{\link{mongo.index.create}()} flag constant - drop duplicate keys. 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/mongo.find.no.cursor.timeout.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.find.no.cursor.timeout} 4 | \alias{mongo.find.no.cursor.timeout} 5 | \title{mongo.find flag constant - no cursor timeout} 6 | \format{\preformatted{ int 16 7 | }} 8 | \usage{ 9 | mongo.find.no.cursor.timeout 10 | } 11 | \value{ 12 | 16L 13 | } 14 | \description{ 15 | \code{\link{mongo.find}()} flag constant - no cursor timeout. 16 | } 17 | \keyword{datasets} 18 | 19 | -------------------------------------------------------------------------------- /man/mongo.binary.md5.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.binary.md5} 4 | \alias{mongo.binary.md5} 5 | \title{BSON binary data subtype constant for md5 data} 6 | \format{\preformatted{ int 5 7 | }} 8 | \usage{ 9 | mongo.binary.md5 10 | } 11 | \value{ 12 | 5L 13 | } 14 | \description{ 15 | BSON binary data subtype constant for md5 data. 16 | } 17 | \seealso{ 18 | \code{\link{mongo.bson.buffer.append.raw}},\cr \link{mongo.bson}. 19 | } 20 | \keyword{datasets} 21 | 22 | -------------------------------------------------------------------------------- /man/mongo.binary.uuid.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.binary.uuid} 4 | \alias{mongo.binary.uuid} 5 | \title{BSON binary data subtype constant for uuid data} 6 | \format{\preformatted{ int 3 7 | }} 8 | \usage{ 9 | mongo.binary.uuid 10 | } 11 | \value{ 12 | 4L 13 | } 14 | \description{ 15 | BSON binary data subtype constant for uuid data. 16 | } 17 | \seealso{ 18 | \code{\link{mongo.bson.buffer.append.raw}},\cr \link{mongo.bson}. 19 | } 20 | \keyword{datasets} 21 | 22 | -------------------------------------------------------------------------------- /man/mongo.binary.user.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.binary.user} 4 | \alias{mongo.binary.user} 5 | \title{BSON binary data subtype constant for user data} 6 | \format{\preformatted{ int 128 7 | }} 8 | \usage{ 9 | mongo.binary.user 10 | } 11 | \value{ 12 | 128L 13 | } 14 | \description{ 15 | BSON binary data subtype constant for user data. 16 | } 17 | \seealso{ 18 | \code{\link{mongo.bson.buffer.append.raw}},\cr \link{mongo.bson}. 19 | } 20 | \keyword{datasets} 21 | 22 | -------------------------------------------------------------------------------- /man/mongo.binary.old.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.binary.old} 4 | \alias{mongo.binary.old} 5 | \title{BSON binary data subtype constant for old format data} 6 | \format{\preformatted{ int 2 7 | }} 8 | \usage{ 9 | mongo.binary.old 10 | } 11 | \value{ 12 | 2L 13 | } 14 | \description{ 15 | BSON binary data subtype constant for old format data (deprecated). 16 | } 17 | \seealso{ 18 | \code{\link{mongo.bson.buffer.append.raw}},\cr \link{mongo.bson}. 19 | } 20 | \keyword{datasets} 21 | 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | rmongodb/Read-and-delete-me 2 | rmongodb/src-i386 3 | rmongodb/src-x64 4 | ipch/ 5 | Debug/ 6 | rmongodb.Rcheck/ 7 | rmongodb.sln 8 | rmongodb.vcxproj 9 | rmongodb.vcxproj.filters 10 | rmongodb.vcxproj.user 11 | rmongodb.opensdf 12 | rmongodb.sdf 13 | rmongodb.suo 14 | rmongodb_*.tar.gz 15 | *.o 16 | src/*.so 17 | src/*.rds 18 | .Rproj.user 19 | .Rhistory 20 | .DS_Store 21 | README.html 22 | vignettes/figure/* 23 | vignettes/*.html 24 | vignettes/*.md 25 | vignettes/*.tex 26 | vignettes/*.log 27 | vignettes/*.sync* 28 | vignettes/*.pdf 29 | -------------------------------------------------------------------------------- /man/mongo.binary.function.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.binary.function} 4 | \alias{mongo.binary.function} 5 | \title{BSON binary data subtype constant for function data} 6 | \format{\preformatted{ int 1 7 | }} 8 | \usage{ 9 | mongo.binary.function 10 | } 11 | \value{ 12 | 1L 13 | } 14 | \description{ 15 | BSON binary data subtype constant for function data. 16 | } 17 | \seealso{ 18 | \code{\link{mongo.bson.buffer.append.raw}},\cr \link{mongo.bson}. 19 | } 20 | \keyword{datasets} 21 | 22 | -------------------------------------------------------------------------------- /man/mongo.binary.binary.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.binary.binary} 4 | \alias{mongo.binary.binary} 5 | \title{BSON binary data subtype constant for standard binary data} 6 | \format{\preformatted{ int 0 7 | }} 8 | \usage{ 9 | mongo.binary.binary 10 | } 11 | \value{ 12 | 0L 13 | } 14 | \description{ 15 | BSON binary data subtype constant for standard binary data. 16 | } 17 | \seealso{ 18 | \code{\link{mongo.bson.buffer.append.raw}},\cr \link{mongo.bson}. 19 | } 20 | \keyword{datasets} 21 | 22 | -------------------------------------------------------------------------------- /R/zzz.R: -------------------------------------------------------------------------------- 1 | .onAttach <- function(libname, pkgname) { 2 | # Runs when attached to search() path such as by library() or require() 3 | if (interactive()) { 4 | packageStartupMessage('WARNING!\nThere are some quite big changes in this version of rmongodb. 5 | mongo.bson.to.list, mongo.bson.from.list (which are workhorses of many other rmongofb high-level functions) are rewritten. 6 | Please, \nTEST IT BEFORE PRODUCTION USAGE.\nAlso there are some other important changes, please see NEWS file and release notes at 7 | https://github.com/mongosoup/rmongodb/releases/') 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /man/mongo.update.basic.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.update.basic} 4 | \alias{mongo.update.basic} 5 | \title{mongo.update() flag constant for performing a basic update} 6 | \format{\preformatted{ int 4 7 | }} 8 | \usage{ 9 | mongo.update.basic 10 | } 11 | \value{ 12 | 4L 13 | } 14 | \description{ 15 | Flag to \code{\link{mongo.update}()} (4L): Perform a basic update. 16 | } 17 | \seealso{ 18 | \code{\link{mongo.update}},\cr \code{\link{mongo.update.multi}}\cr 19 | \code{\link{mongo.update.upsert}} 20 | } 21 | \keyword{datasets} 22 | 23 | -------------------------------------------------------------------------------- /man/mongo.update.upsert.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.update.upsert} 4 | \alias{mongo.update.upsert} 5 | \title{mongo.update() flag constant for an upsert} 6 | \format{\preformatted{ int 1 7 | }} 8 | \usage{ 9 | mongo.update.upsert 10 | } 11 | \value{ 12 | 1L 13 | } 14 | \description{ 15 | Flag to \code{\link{mongo.update}()} (1L): insert ObjNew into the database 16 | if no record matching criteria is found. 17 | } 18 | \seealso{ 19 | \code{\link{mongo.update}},\cr \code{\link{mongo.update.multi}},\cr 20 | \code{\link{mongo.update.basic}}. 21 | } 22 | \keyword{datasets} 23 | 24 | -------------------------------------------------------------------------------- /man/mongo.update.multi.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.update.multi} 4 | \alias{mongo.update.multi} 5 | \title{mongo.update() flag constant for updating multiple records} 6 | \format{\preformatted{ int 2 7 | }} 8 | \usage{ 9 | mongo.update.multi 10 | } 11 | \value{ 12 | 2L 13 | } 14 | \description{ 15 | Flag to \code{\link{mongo.update}()} (2L): Update multiple records rather 16 | than just the first one matched by criteria. 17 | } 18 | \seealso{ 19 | \code{\link{mongo.update}},\cr 20 | \code{\link{mongo.update.upsert}},\cr \code{\link{mongo.update.basic}}. 21 | } 22 | \keyword{datasets} 23 | 24 | -------------------------------------------------------------------------------- /man/mongo.reconnect.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.reconnect} 3 | \alias{mongo.reconnect} 4 | \title{Reconnect to a MongoDB server} 5 | \usage{ 6 | mongo.reconnect(mongo) 7 | } 8 | \arguments{ 9 | \item{mongo}{(\link{mongo}) a mongo connection object.} 10 | } 11 | \description{ 12 | Reconnect to a MongoDB server. Calls mongo.disconnect and then attempts to 13 | re-establish the connection. 14 | } 15 | \examples{ 16 | mongo <- mongo.create() 17 | if (mongo.is.connected(mongo)) 18 | mongo.reconnect(mongo) 19 | } 20 | \seealso{ 21 | \code{\link{mongo.create}},\cr \code{\link{mongo.disconnect}},\cr 22 | \link{mongo}. 23 | } 24 | 25 | -------------------------------------------------------------------------------- /man/mongo.bson.date.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.bson.date} 4 | \alias{mongo.bson.date} 5 | \title{BSON data type constant for a date value} 6 | \format{\preformatted{ int 9 7 | }} 8 | \usage{ 9 | mongo.bson.date 10 | } 11 | \value{ 12 | 9L 13 | } 14 | \description{ 15 | \code{\link{mongo.bson.iterator.type}()} and 16 | \code{\link{mongo.bson.iterator.next}()} will return this constant (9L) to 17 | indicate that the value pointer to by an iterator is a date/time. 18 | } 19 | \seealso{ 20 | \code{\link{mongo.bson.iterator.type}},\cr 21 | \code{\link{mongo.bson.iterator.next}},\cr \link{mongo.bson}. 22 | } 23 | \keyword{datasets} 24 | 25 | -------------------------------------------------------------------------------- /man/mongo.bson.null.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.bson.null} 4 | \alias{mongo.bson.null} 5 | \title{BSON data type constant for a null value} 6 | \format{\preformatted{ int 10 7 | }} 8 | \usage{ 9 | mongo.bson.null 10 | } 11 | \value{ 12 | 10L 13 | } 14 | \description{ 15 | \code{\link{mongo.bson.iterator.type}()} and 16 | \code{\link{mongo.bson.iterator.next}()} will return this constant (10L) to 17 | indicate that the value pointer to by an iterator is a null. 18 | } 19 | \seealso{ 20 | \code{\link{mongo.bson.iterator.type}},\cr 21 | \code{\link{mongo.bson.iterator.next}},\cr \link{mongo.bson}. 22 | } 23 | \keyword{datasets} 24 | 25 | -------------------------------------------------------------------------------- /man/mongo.bson.oid.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.bson.oid} 4 | \alias{mongo.bson.oid} 5 | \title{BSON data type constant for a oid value} 6 | \format{\preformatted{ int 7 7 | }} 8 | \usage{ 9 | mongo.bson.oid 10 | } 11 | \value{ 12 | 7L 13 | } 14 | \description{ 15 | \code{\link{mongo.bson.iterator.type}()} and 16 | \code{\link{mongo.bson.iterator.next}()} will return this constant (7L) to 17 | indicate that the value pointer to by an iterator is a oid (Object ID). 18 | } 19 | \seealso{ 20 | \code{\link{mongo.bson.iterator.type}},\cr 21 | \code{\link{mongo.bson.iterator.next}},\cr \link{mongo.bson}. 22 | } 23 | \keyword{datasets} 24 | 25 | -------------------------------------------------------------------------------- /man/mongo.bson.code.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.bson.code} 4 | \alias{mongo.bson.code} 5 | \title{BSON data type constant for a code value} 6 | \format{\preformatted{ int 13 7 | }} 8 | \usage{ 9 | mongo.bson.code 10 | } 11 | \value{ 12 | 13L 13 | } 14 | \description{ 15 | \code{\link{mongo.bson.iterator.type}()} and 16 | \code{\link{mongo.bson.iterator.next}()} will return this constant (13L) to 17 | indicate that the value pointer to by an iterator is javascript code. 18 | } 19 | \seealso{ 20 | \code{\link{mongo.bson.iterator.type}},\cr 21 | \code{\link{mongo.bson.iterator.next}},\cr \link{mongo.bson}. 22 | } 23 | \keyword{datasets} 24 | 25 | -------------------------------------------------------------------------------- /man/mongo.bson.double.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.bson.double} 4 | \alias{mongo.bson.double} 5 | \title{BSON data type constant for a double value} 6 | \format{\preformatted{ int 1 7 | }} 8 | \usage{ 9 | mongo.bson.double 10 | } 11 | \value{ 12 | 1L 13 | } 14 | \description{ 15 | \code{\link{mongo.bson.iterator.type}()} and 16 | \code{\link{mongo.bson.iterator.next}()} will return this constant (1L) to 17 | indicate that the value pointer to by an iterator is a double. 18 | } 19 | \seealso{ 20 | \code{\link{mongo.bson.iterator.type}},\cr 21 | \code{\link{mongo.bson.iterator.next}},\cr \link{mongo.bson}. 22 | } 23 | \keyword{datasets} 24 | 25 | -------------------------------------------------------------------------------- /man/mongo.bson.int.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.bson.int} 4 | \alias{mongo.bson.int} 5 | \title{BSON data type constant for a integer value} 6 | \format{\preformatted{ int 16 7 | }} 8 | \usage{ 9 | mongo.bson.int 10 | } 11 | \value{ 12 | 16L 13 | } 14 | \description{ 15 | \code{\link{mongo.bson.iterator.type}()} and 16 | \code{\link{mongo.bson.iterator.next}()} will return this constant (16L) to 17 | indicate that the value pointer to by an iterator is a integer (32-bit). 18 | } 19 | \seealso{ 20 | \code{\link{mongo.bson.iterator.type}},\cr 21 | \code{\link{mongo.bson.iterator.next}},\cr \link{mongo.bson}. 22 | } 23 | \keyword{datasets} 24 | 25 | -------------------------------------------------------------------------------- /man/mongo.bson.string.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.bson.string} 4 | \alias{mongo.bson.string} 5 | \title{BSON data type constant for a string value} 6 | \format{\preformatted{ int 2 7 | }} 8 | \usage{ 9 | mongo.bson.string 10 | } 11 | \value{ 12 | 2L 13 | } 14 | \description{ 15 | \code{\link{mongo.bson.iterator.type}()} and 16 | \code{\link{mongo.bson.iterator.next}()} will return this constant (2L) to 17 | indicate that the value pointer to by an iterator is a string. 18 | } 19 | \seealso{ 20 | \code{\link{mongo.bson.iterator.type}},\cr 21 | \code{\link{mongo.bson.iterator.next}},\cr \link{mongo.bson}. 22 | } 23 | \keyword{datasets} 24 | 25 | -------------------------------------------------------------------------------- /man/mongo.bson.symbol.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.bson.symbol} 4 | \alias{mongo.bson.symbol} 5 | \title{BSON data type constant for a symbol value} 6 | \format{\preformatted{ int 14 7 | }} 8 | \usage{ 9 | mongo.bson.symbol 10 | } 11 | \value{ 12 | 14L 13 | } 14 | \description{ 15 | \code{\link{mongo.bson.iterator.type}()} and 16 | \code{\link{mongo.bson.iterator.next}()} will return this constant (14L) to 17 | indicate that the value pointer to by an iterator is a symbol. 18 | } 19 | \seealso{ 20 | \code{\link{mongo.bson.iterator.type}},\cr 21 | \code{\link{mongo.bson.iterator.next}},\cr \link{mongo.bson}. 22 | } 23 | \keyword{datasets} 24 | 25 | -------------------------------------------------------------------------------- /man/mongo.get.socket.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.get.socket} 3 | \alias{mongo.get.socket} 4 | \title{Get the socket assigned to a mongo object by mongo.create().} 5 | \usage{ 6 | mongo.get.socket(mongo) 7 | } 8 | \arguments{ 9 | \item{mongo}{(\link{mongo}) a mongo connection object.} 10 | } 11 | \value{ 12 | Integer socket number 13 | } 14 | \description{ 15 | Get the the low-level socket number assigned to the given mongo object by 16 | mongo.create(). 17 | } 18 | \examples{ 19 | mongo <- mongo.create() 20 | if (mongo.is.connected(mongo)) 21 | print(mongo.get.socket(mongo)) 22 | } 23 | \seealso{ 24 | \code{\link{mongo.create}},\cr \link{mongo}. 25 | } 26 | 27 | -------------------------------------------------------------------------------- /man/mongo.bson.eoo.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.bson.eoo} 4 | \alias{mongo.bson.eoo} 5 | \title{BSON data type constant for 'End Of Object'} 6 | \format{\preformatted{ int 0 7 | }} 8 | \usage{ 9 | mongo.bson.eoo 10 | } 11 | \value{ 12 | 0L 13 | } 14 | \description{ 15 | \code{\link{mongo.bson.iterator.type}()} and 16 | \code{\link{mongo.bson.iterator.next}()} will return this constant (0L) at 17 | the end of the object when there are no more fields through which to 18 | iterate. 19 | } 20 | \seealso{ 21 | \code{\link{mongo.bson.iterator.type}},\cr 22 | \code{\link{mongo.bson.iterator.next}},\cr \link{mongo.bson}. 23 | } 24 | \keyword{datasets} 25 | 26 | -------------------------------------------------------------------------------- /man/mongo.bson.object.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.bson.object} 4 | \alias{mongo.bson.object} 5 | \title{BSON data type constant for a subobject value} 6 | \format{\preformatted{ int 3 7 | }} 8 | \usage{ 9 | mongo.bson.object 10 | } 11 | \value{ 12 | 3L 13 | } 14 | \description{ 15 | \code{\link{mongo.bson.iterator.type}()} and 16 | \code{\link{mongo.bson.iterator.next}()} will return this constant (3L) to 17 | indicate that the value pointer to by an iterator is a subobject. 18 | } 19 | \seealso{ 20 | \code{\link{mongo.bson.iterator.type}},\cr 21 | \code{\link{mongo.bson.iterator.next}},\cr \link{mongo.bson}. 22 | } 23 | \keyword{datasets} 24 | 25 | -------------------------------------------------------------------------------- /man/mongo.bson.long.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.bson.long} 4 | \alias{mongo.bson.long} 5 | \title{BSON data type constant for a long value} 6 | \format{\preformatted{ int 18 7 | }} 8 | \usage{ 9 | mongo.bson.long 10 | } 11 | \value{ 12 | 18L 13 | } 14 | \description{ 15 | \code{\link{mongo.bson.iterator.type}()} and 16 | \code{\link{mongo.bson.iterator.next}()} will return this constant (18L) to 17 | indicate that the value pointer to by an iterator is a long integer (64 18 | bits). 19 | } 20 | \seealso{ 21 | \code{\link{mongo.bson.iterator.type}},\cr 22 | \code{\link{mongo.bson.iterator.next}},\cr \link{mongo.bson}. 23 | } 24 | \keyword{datasets} 25 | 26 | -------------------------------------------------------------------------------- /man/mongo.bson.regex.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.bson.regex} 4 | \alias{mongo.bson.regex} 5 | \title{BSON data type constant for a regex value} 6 | \format{\preformatted{ int 11 7 | }} 8 | \usage{ 9 | mongo.bson.regex 10 | } 11 | \value{ 12 | 11L 13 | } 14 | \description{ 15 | \code{\link{mongo.bson.iterator.type}()} and 16 | \code{\link{mongo.bson.iterator.next}()} will return this constant (11L) to 17 | indicate that the value pointer to by an iterator is a regular expression. 18 | } 19 | \seealso{ 20 | \code{\link{mongo.bson.iterator.type}},\cr 21 | \code{\link{mongo.bson.iterator.next}},\cr \link{mongo.bson}. 22 | } 23 | \keyword{datasets} 24 | 25 | -------------------------------------------------------------------------------- /man/mongo.bson.undefined.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.bson.undefined} 4 | \alias{mongo.bson.undefined} 5 | \title{BSON data type constant for a undefined value} 6 | \format{\preformatted{ int 6 7 | }} 8 | \usage{ 9 | mongo.bson.undefined 10 | } 11 | \value{ 12 | 6L 13 | } 14 | \description{ 15 | \code{\link{mongo.bson.iterator.type}()} and 16 | \code{\link{mongo.bson.iterator.next}()} will return this constant (6L) to 17 | indicate that the value pointer to by an iterator is a undefined. 18 | } 19 | \seealso{ 20 | \code{\link{mongo.bson.iterator.type}},\cr 21 | \code{\link{mongo.bson.iterator.next}},\cr \link{mongo.bson}. 22 | } 23 | \keyword{datasets} 24 | 25 | -------------------------------------------------------------------------------- /man/mongo.bson.bool.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.bson.bool} 4 | \alias{mongo.bson.bool} 5 | \title{BSON data type constant for a bool value} 6 | \format{\preformatted{ int 8 7 | }} 8 | \usage{ 9 | mongo.bson.bool 10 | } 11 | \value{ 12 | 8L 13 | } 14 | \description{ 15 | \code{\link{mongo.bson.iterator.type}()} and 16 | \code{\link{mongo.bson.iterator.next}()} will return this constant (8L) to 17 | indicate that the value pointer to by an iterator is a bool. 18 | } 19 | \seealso{ 20 | \code{\link{mongo.bson.iterator.type}},\cr 21 | \code{\link{mongo.bson.iterator.next}},\cr \link{mongo.bson.iterator},\cr 22 | \link{mongo.bson}. 23 | } 24 | \keyword{datasets} 25 | 26 | -------------------------------------------------------------------------------- /man/mongo.bson.timestamp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.bson.timestamp} 4 | \alias{mongo.bson.timestamp} 5 | \title{BSON data type constant for a timestamp value} 6 | \format{\preformatted{ int 17 7 | }} 8 | \usage{ 9 | mongo.bson.timestamp 10 | } 11 | \value{ 12 | 17L 13 | } 14 | \description{ 15 | \code{\link{mongo.bson.iterator.type}()} and 16 | \code{\link{mongo.bson.iterator.next}()} will return this constant (17L) to 17 | indicate that the value pointer to by an iterator is a timestamp. 18 | } 19 | \seealso{ 20 | \code{\link{mongo.bson.iterator.type}},\cr 21 | \code{\link{mongo.bson.iterator.next}},\cr \link{mongo.bson}. 22 | } 23 | \keyword{datasets} 24 | 25 | -------------------------------------------------------------------------------- /man/mongo.bson.binary.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.bson.binary} 4 | \alias{mongo.bson.binary} 5 | \title{BSON data type constant for a binary data value} 6 | \format{\preformatted{ int 5 7 | }} 8 | \usage{ 9 | mongo.bson.binary 10 | } 11 | \value{ 12 | 5L 13 | } 14 | \description{ 15 | \code{\link{mongo.bson.iterator.type}()} and 16 | \code{\link{mongo.bson.iterator.next}()} will return this constant (5L) to 17 | indicate that the value pointer to by an iterator is binary data. 18 | } 19 | \seealso{ 20 | \code{\link{mongo.bson.iterator.type}},\cr 21 | \code{\link{mongo.bson.iterator.next}},\cr \link{mongo.bson.iterator},\cr 22 | \link{mongo.bson}. 23 | } 24 | \keyword{datasets} 25 | 26 | -------------------------------------------------------------------------------- /man/mongo.bson.buffer.create.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.buffer.create} 3 | \alias{mongo.bson.buffer.create} 4 | \title{Create an new mongo.bson.buffer object} 5 | \usage{ 6 | mongo.bson.buffer.create() 7 | } 8 | \value{ 9 | A fresh \link{mongo.bson.buffer} object 10 | } 11 | \description{ 12 | Returns a fresh mongo.bson.buffer object ready to have data appended onto 13 | it. 14 | } 15 | \details{ 16 | mongo.bson.buffer objects are used to build mongo.bson objects. 17 | } 18 | \examples{ 19 | buf <- mongo.bson.buffer.create() 20 | mongo.bson.buffer.append(buf, "name", "Donna") 21 | b <- mongo.bson.from.buffer(buf) 22 | } 23 | \seealso{ 24 | \link{mongo.bson},\cr \link{mongo.bson.buffer}. 25 | } 26 | 27 | -------------------------------------------------------------------------------- /man/mongo.bson.array.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.bson.array} 4 | \alias{mongo.bson.array} 5 | \title{BSON data type constant for an array} 6 | \format{\preformatted{ int 4 7 | }} 8 | \usage{ 9 | mongo.bson.array 10 | } 11 | \value{ 12 | 4L 13 | } 14 | \description{ 15 | \code{\link{mongo.bson.iterator.type}()} and 16 | \code{\link{mongo.bson.iterator.next}()} will return this constant (4L) to 17 | indicate that the value pointer to by an iterator is an array (containing 18 | child values). 19 | } 20 | \seealso{ 21 | \code{\link{mongo.bson.iterator.type}},\cr 22 | \code{\link{mongo.bson.iterator.next}},\cr \link{mongo.bson.iterator},\cr 23 | \link{mongo.bson}. 24 | } 25 | \keyword{datasets} 26 | 27 | -------------------------------------------------------------------------------- /man/mongo.bson.code.w.scope.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.bson.code.w.scope} 4 | \alias{mongo.bson.code.w.scope} 5 | \title{BSON data type constant for a code with scope value} 6 | \format{\preformatted{ int 15 7 | }} 8 | \usage{ 9 | mongo.bson.code.w.scope 10 | } 11 | \value{ 12 | 15L 13 | } 14 | \description{ 15 | \code{\link{mongo.bson.iterator.type}()} and 16 | \code{\link{mongo.bson.iterator.next}()} will return this constant (15L) to 17 | indicate that the value pointer to by an iterator is a javascript with a 18 | scope. 19 | } 20 | \seealso{ 21 | \code{\link{mongo.bson.iterator.type}},\cr 22 | \code{\link{mongo.bson.iterator.next}},\cr \link{mongo.bson} 23 | } 24 | \keyword{datasets} 25 | 26 | -------------------------------------------------------------------------------- /man/mongo.bson.destroy.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.destroy} 3 | \alias{mongo.bson.destroy} 4 | \title{Destroy a mongo.bson object} 5 | \usage{ 6 | mongo.bson.destroy(b) 7 | } 8 | \arguments{ 9 | \item{b}{A (\link{mongo.bson}) object.} 10 | } 11 | \description{ 12 | Releases the resources associated with a \link{mongo.bson} object. It is not 13 | absolutely necessary to call this function since R's garbage collection will 14 | eventually get around to doing it for you. 15 | } 16 | \examples{ 17 | b <- mongo.bson.from.list(list(name="Cheryl", age=29)) 18 | print(b) 19 | mongo.bson.destroy(b) 20 | } 21 | \seealso{ 22 | \link{mongo.bson},\cr \code{\link{mongo.bson.from.list}},\cr 23 | \code{\link{mongo.bson.from.buffer}}. 24 | } 25 | 26 | -------------------------------------------------------------------------------- /man/mongo.get.primary.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.get.primary} 3 | \alias{mongo.get.primary} 4 | \title{Get the host & port of the server to which a mongo object is connected.} 5 | \usage{ 6 | mongo.get.primary(mongo) 7 | } 8 | \arguments{ 9 | \item{mongo}{(\link{mongo}) a mongo connection object.} 10 | } 11 | \value{ 12 | String host & port in the format "\%s:\%d". 13 | } 14 | \description{ 15 | Get the host & port of the server to which a mongo object is connected. 16 | } 17 | \examples{ 18 | \dontrun{ 19 | mongo <- mongo.create(c("127.0.0.1", "192.168.0.3")) 20 | if (mongo.is.connected(mongo)) { 21 | print(mongo.get.primary(mongo)) 22 | } 23 | } 24 | } 25 | \seealso{ 26 | \code{\link{mongo.create}},\cr \link{mongo}. 27 | } 28 | 29 | -------------------------------------------------------------------------------- /man/mongo.is.connected.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.is.connected} 3 | \alias{mongo.is.connected} 4 | \title{Determine if a mongo object is connected to a MongoDB server} 5 | \usage{ 6 | mongo.is.connected(mongo) 7 | } 8 | \arguments{ 9 | \item{mongo}{(\link{mongo}) a mongo connection object.} 10 | } 11 | \value{ 12 | Logical TRUE if the mongo connection object is currently connected 13 | to a server; otherwise, FALSE. 14 | } 15 | \description{ 16 | Returns TRUE if the parameter mongo object is connected to a MongoDB server; 17 | otherwise, FALSE. 18 | } 19 | \examples{ 20 | mongo <- mongo.create() 21 | if (mongo.is.connected(mongo)) { 22 | print(mongo.count(mongo, "test.people")) 23 | } 24 | } 25 | \seealso{ 26 | \code{\link{mongo.create}},\cr \link{mongo}. 27 | } 28 | 29 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: rmongodb 2 | Type: Package 3 | Title: R-MongoDB driver 4 | Version: 1.8.0 5 | Date: 2014-11-01 6 | Depends: 7 | R (>= 2.10) 8 | Imports: 9 | jsonlite, 10 | plyr 11 | Author: MongoDB, Inc. (mongo-c-driver) & Markus Schmidberger (mongosoup.de). 12 | Formerly Gerald Lindsly. 13 | Maintainer: Dmitriy Selivanov 14 | Description: This R package provides an interface to the NoSQL MongoDB database 15 | using the MongoDB C-driver version 0.8. 16 | License: Apache License 2.0 17 | URL: https://github.com/mongosoup/rmongodb, 18 | http://stackoverflow.com/questions/tagged/rmongodb 19 | BugReports: https://github.com/mongosoup/rmongodb/issues 20 | SystemRequirements: MongoDB, GNU make 21 | Suggests: 22 | RUnit, 23 | knitr 24 | VignetteBuilder: knitr 25 | NeedsCompilation: yes 26 | -------------------------------------------------------------------------------- /man/mongo.get.timeout.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.get.timeout} 3 | \alias{mongo.get.timeout} 4 | \title{Get the timeout value of a mongo connection} 5 | \usage{ 6 | mongo.get.timeout(mongo) 7 | } 8 | \arguments{ 9 | \item{mongo}{(\link{mongo}) a mongo connection object.} 10 | } 11 | \value{ 12 | (integer) timeout value in milliseconds. 13 | } 14 | \description{ 15 | Get the timeout value for network operations on a mongo connection. 16 | } 17 | \examples{ 18 | mongo <- mongo.create() 19 | if (mongo.is.connected(mongo)) { 20 | mongo.set.timeout(mongo, 2000L) 21 | timeout <- mongo.get.timeout(mongo) 22 | if (timeout != 2000L) 23 | error("expected timeout of 2000"); 24 | } 25 | } 26 | \seealso{ 27 | \code{\link{mongo.set.timeout}},\cr \code{\link{mongo.create}},\cr 28 | \link{mongo}. 29 | } 30 | 31 | -------------------------------------------------------------------------------- /man/mongo.bson.from.JSON.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.from.JSON} 3 | \alias{mongo.bson.from.JSON} 4 | \title{Convert JSON to BSON Object} 5 | \usage{ 6 | mongo.bson.from.JSON(JSON, simplifyVector = FALSE, ...) 7 | } 8 | \arguments{ 9 | \item{JSON}{(string) A valid JSON string.} 10 | 11 | \item{simplifyVector}{(FALSE) coerse JSON arrays containing only scalars into a vector.} 12 | 13 | \item{...}{additional parameters parsed to fromJSON} 14 | } 15 | \value{ 16 | A BSON object. 17 | } 18 | \description{ 19 | Converts a JSON string to a mongo BSON object. 20 | } 21 | \examples{ 22 | mongo.bson.from.JSON('{"name" : "Peter"}') 23 | mongo.bson.from.JSON('{"_id" : 1}') 24 | } 25 | \seealso{ 26 | \code{\link{mongo.find}},\cr \code{\link{mongo.bson.from.list}}, \cr \code{\link{mongo.bson}} 27 | , \cr \code{\link{fromJSON}}. 28 | } 29 | 30 | -------------------------------------------------------------------------------- /man/mongo.get.hosts.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.get.hosts} 3 | \alias{mongo.get.hosts} 4 | \title{Get a lists of hosts & ports as reported by a replica set master upon 5 | connection creation.} 6 | \usage{ 7 | mongo.get.hosts(mongo) 8 | } 9 | \arguments{ 10 | \item{mongo}{(\link{mongo}) a mongo connection object.} 11 | } 12 | \value{ 13 | NULL if a replica set was not connected to; otherwise, a list of 14 | host & port strings in the format "%s:%d". 15 | } 16 | \description{ 17 | Get a lists of hosts & ports as reported by a replica set master upon 18 | connection creation. 19 | } 20 | \examples{ 21 | \dontrun{ 22 | mongo <- mongo.create(c("127.0.0.1", "192.168.0.3"), name="Inventory") 23 | if (mongo.is.connected(mongo)) 24 | print(mongo.get.hosts(mongo)) 25 | } 26 | } 27 | \seealso{ 28 | \code{\link{mongo.create}},\cr \link{mongo} 29 | } 30 | 31 | -------------------------------------------------------------------------------- /tests/test_bson_iterator.R: -------------------------------------------------------------------------------- 1 | library(rmongodb) 2 | library(RUnit) 3 | 4 | # 2 tests 5 | # 22.11.2013 6 | 7 | 8 | # test create bson object with values 9 | r <- as.integer(c(1,2,3,4,5,6,7,8)) 10 | dim(r) <- c(2,2,2) 11 | t <- Sys.time() 12 | t <- c(t, t+10, t+60, t+120) 13 | dim(t) <- c(2,2) 14 | buf <- mongo.bson.buffer.create() 15 | mongo.bson.buffer.append.int(buf, "test", r) 16 | mongo.bson.buffer.append(buf, "times", t) 17 | b <- mongo.bson.from.buffer(buf) 18 | 19 | # iterate over bson object 20 | iter <- mongo.bson.iterator.create(b) 21 | while (mongo.bson.iterator.next(iter)) { 22 | print(mongo.bson.iterator.key(iter)) 23 | print(mongo.bson.iterator.value(iter)) 24 | } 25 | 26 | iter <- mongo.bson.find(b, "test") 27 | out <- mongo.bson.iterator.value(iter) 28 | checkEquals( out, r ) 29 | 30 | sub2 <- mongo.bson.value(b, "times") 31 | checkEqualsNumeric( sub2, t, tolerance=1.0e-6) 32 | -------------------------------------------------------------------------------- /man/mongo.oid.print.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.oid.print} 3 | \alias{mongo.oid.print} 4 | \title{Display a mongo.oid object} 5 | \usage{ 6 | mongo.oid.print(x) 7 | } 8 | \arguments{ 9 | \item{x}{\link{mongo.oid} The object to display.} 10 | } 11 | \value{ 12 | The parameter is returned unchanged. 13 | } 14 | \description{ 15 | Display formatted output of a \link{mongo.oid} object. 16 | } 17 | \details{ 18 | This version is an alias of \code{\link{print.mongo.oid}()} which allows 19 | \code{print()} to properly handle the mongo.oid class. 20 | } 21 | \examples{ 22 | oid <- mongo.oid.create() 23 | 24 | # all display the same thing 25 | print.mongo.oid(oid) 26 | mongo.oid.print(oid) 27 | print(oid) 28 | } 29 | \seealso{ 30 | \code{\link{mongo.oid.print}},\cr 31 | \code{\link{mongo.oid.to.string}},\cr \link{mongo.bson.oid},\cr 32 | \link{mongo.bson}. 33 | } 34 | 35 | -------------------------------------------------------------------------------- /man/mongo.get.databases.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.get.databases} 3 | \alias{mongo.get.databases} 4 | \title{Get a list of databases from a MongoDB server} 5 | \usage{ 6 | mongo.get.databases(mongo) 7 | } 8 | \arguments{ 9 | \item{mongo}{(\link{mongo}) A mongo connection object.} 10 | } 11 | \value{ 12 | (string vector) List of databases. Note this will not include the 13 | system databases "admin" and "local". 14 | } 15 | \description{ 16 | Get a list of databases from a MongoDB server. 17 | } 18 | \examples{ 19 | mongo <- mongo.create() 20 | if (mongo.is.connected(mongo)) { 21 | print(mongo.get.databases(mongo)) 22 | 23 | mongo.destroy(mongo) 24 | } 25 | } 26 | \seealso{ 27 | \code{\link{mongo.get.database.collections}},\cr 28 | \code{\link{mongo.drop.database}},\cr \code{\link{mongo.command}},\cr 29 | \code{\link{mongo.rename}},\cr \link{mongo}. 30 | } 31 | 32 | -------------------------------------------------------------------------------- /man/zips.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{zips} 4 | \alias{Dataset} 5 | \alias{zips} 6 | \title{zips Dataset} 7 | \format{The _id field holds the zip code as a string. 8 | 9 | The city field holds the city. 10 | 11 | The state field holds the two letter state abbreviation. 12 | 13 | The pop field holds the population. 14 | 15 | The loc field holds the location as a latitude longitude pair.} 16 | \source{ 17 | \url{http://media.mongodb.org/zips.json} 18 | } 19 | \description{ 20 | A dataset with US zip data provided by mongodb for education. 21 | } 22 | \examples{ 23 | \dontrun{ 24 | # code to create the dataset 25 | library(RJSONIO) 26 | 27 | json_file <- "http://media.mongodb.org/zips.json" 28 | 29 | rL <- readLines(json_file) 30 | 31 | zips <- do.call(rbind,lapply(rL,fromJSON)) 32 | 33 | save(zips, file="data/zips.rda", compress="xz") 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /man/mongo.bson.size.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.size} 3 | \alias{mongo.bson.size} 4 | \title{Get the size of a mongo.bson object} 5 | \usage{ 6 | mongo.bson.size(b) 7 | } 8 | \arguments{ 9 | \item{b}{(\link{mongo.bson}) the mongo.bson object to examine.} 10 | } 11 | \value{ 12 | (integer) the number of bytes taken up by the BSON data attached to 13 | the mongo.bson object. 14 | } 15 | \description{ 16 | Get the number of bytes taken up by the BSON data attached to the mongo.bson 17 | object 18 | } 19 | \examples{ 20 | # should report 5 21 | print(mongo.bson.size(mongo.bson.empty())) 22 | 23 | buf <- mongo.bson.buffer.create() 24 | mongo.bson.buffer.append(buf, "name", "Fred") 25 | mongo.bson.buffer.append(buf, "city", "Dayton") 26 | y <- mongo.bson.from.buffer(buf) 27 | # should report 37 28 | print(mongo.bson.size(y)) 29 | } 30 | \seealso{ 31 | \link{mongo.bson} 32 | } 33 | 34 | -------------------------------------------------------------------------------- /man/mongo.disconnect.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.disconnect} 3 | \alias{mongo.disconnect} 4 | \title{Disconnect from a MongoDB server} 5 | \usage{ 6 | mongo.disconnect(mongo) 7 | } 8 | \arguments{ 9 | \item{mongo}{(\link{mongo}) a mongo connection object.} 10 | } 11 | \value{ 12 | The mongo object is returned. 13 | } 14 | \description{ 15 | Disconnect from a MongoDB server. No further communication is possible on 16 | the connection. However, \code{\link{mongo.reconnect}()} may be called on 17 | the mongo object to restablish the connection. 18 | } 19 | \examples{ 20 | mongo <- mongo.create() 21 | if (mongo.is.connected(mongo)) { 22 | n_people <- mongo.count(mongo, "test.people") 23 | mongo.disconnect(mongo) 24 | } 25 | } 26 | \seealso{ 27 | \link{mongo},\cr \code{\link{mongo.create}},\cr 28 | \code{\link{mongo.reconnect}},\cr \code{\link{mongo.is.connected}}. 29 | } 30 | 31 | -------------------------------------------------------------------------------- /man/mongo.gridfs.remove.file.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.gridfs.remove.file} 3 | \alias{mongo.gridfs.remove.file} 4 | \title{Remove a file from a GridFS on a MongoDB server} 5 | \usage{ 6 | mongo.gridfs.remove.file(gridfs, remotename) 7 | } 8 | \arguments{ 9 | \item{gridfs}{A (\link{mongo.gridfs}) object.} 10 | 11 | \item{remotename}{(string) The name of the file to be removed (as known 12 | within the GridFS).} 13 | } 14 | \description{ 15 | Remove a file from a GridFS on a MongoDB server. 16 | } 17 | \examples{ 18 | mongo <- mongo.create() 19 | if (mongo.is.connected(mongo)) { 20 | gridfs <- mongo.gridfs.create(mongo, "grid") 21 | \dontrun{mongo.gridfs.remove.file(gridfs, "test.R")} 22 | mongo.gridfs.destroy(gridfs) 23 | } 24 | } 25 | \seealso{ 26 | \link{mongo.gridfs},\cr \code{\link{mongo.gridfs.store.file}}\cr 27 | \code{\link{mongo.gridfs.store}}. 28 | } 29 | 30 | -------------------------------------------------------------------------------- /src/helpers.c: -------------------------------------------------------------------------------- 1 | /* Dmitriy Selivanov (2014) https://github.com/dselivanov */ 2 | #include 3 | #include "helpers.h" 4 | 5 | // check for NA values. 6 | // returns vector of flags whether element is NA 7 | // this function is from "Advanced R" (http://adv-r.had.co.nz/C-interface.html) by Hadley Wickham. 8 | int* _IS_NA(SEXP x) { 9 | int n = length(x); 10 | int* is_na = malloc(n * sizeof(int)); 11 | for (int i = 0; i < n; i++) { 12 | switch(TYPEOF(x)) { 13 | case LGLSXP: 14 | is_na[i] = (LOGICAL(x)[i] == NA_LOGICAL); 15 | break; 16 | case INTSXP: 17 | is_na[i] = (INTEGER(x)[i] == NA_INTEGER); 18 | break; 19 | case REALSXP: 20 | is_na[i] = ISNA(REAL(x)[i]) || ISNAN(REAL(x)[i]); 21 | break; 22 | case STRSXP: 23 | is_na[i] = (STRING_ELT(x, i) == NA_STRING); 24 | break; 25 | default: 26 | is_na[i] = 0; 27 | } 28 | } 29 | return is_na; 30 | } 31 | -------------------------------------------------------------------------------- /man/mongo.bson.print.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.print} 3 | \alias{mongo.bson.print} 4 | \title{Display a mongo.bson object} 5 | \usage{ 6 | mongo.bson.print(x, ...) 7 | } 8 | \arguments{ 9 | \item{x}{(\link{mongo.bson}) The mongo.bson object to display.} 10 | 11 | \item{...}{Parameters passed from generic.} 12 | } 13 | \value{ 14 | The parameter is returned unchanged. 15 | } 16 | \description{ 17 | Display formatted output of a mongo.bson object. 18 | } 19 | \details{ 20 | Output is tabbed (indented to show the nesting level of subobjects and 21 | arrays). 22 | } 23 | \examples{ 24 | buf <- mongo.bson.buffer.create() 25 | mongo.bson.buffer.append(buf, "name", "Fred") 26 | mongo.bson.buffer.append(buf, "city", "Dayton") 27 | b <- mongo.bson.from.buffer(buf) 28 | 29 | # all display the same thing 30 | mongo.bson.print(b) 31 | print.mongo.bson(b) 32 | print(b) 33 | } 34 | \seealso{ 35 | \link{mongo.bson} 36 | } 37 | 38 | -------------------------------------------------------------------------------- /man/mongo.bson.empty.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.empty} 3 | \alias{mongo.bson.empty} 4 | \title{Create an empty mongo.bson object} 5 | \usage{ 6 | mongo.bson.empty() 7 | } 8 | \value{ 9 | An empty mongo.bson object 10 | } 11 | \description{ 12 | Returns an empty mongo.bson object. mongo.bson objects have "mongo.bson" as 13 | their class and contain an externally managed pointer to the actual data. 14 | This pointer is stored in the "mongo.bson" attribute of the object. 15 | } 16 | \examples{ 17 | # Use an empty mongo.bson for the query object which matches everything. 18 | # This happens to be the default value for the query 19 | # parameter to mongo.count, but we explicity use mongo.bson.empty() 20 | # here for an example. 21 | mongo <- mongo.create() 22 | if (mongo.is.connected(mongo)) 23 | print(mongo.count(mongo, "test.people", query=mongo.bson.empty())) 24 | } 25 | \seealso{ 26 | \link{mongo.bson} 27 | } 28 | 29 | -------------------------------------------------------------------------------- /man/mongo.oid.time.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.oid.time} 3 | \alias{mongo.oid.time} 4 | \title{Get an Object ID's time} 5 | \usage{ 6 | mongo.oid.time(oid) 7 | } 8 | \arguments{ 9 | \item{oid}{(\link{mongo.oid}) The OID to be examined.} 10 | } 11 | \value{ 12 | (integer) ("POSIXct") The time portion of the given \code{oid}. 13 | } 14 | \description{ 15 | Get the 32-bit UTC time portion of an OID (Object ID). 16 | } 17 | \details{ 18 | See \url{http://www.mongodb.org/display/DOCS/Object+IDs} 19 | } 20 | \examples{ 21 | oid <- mongo.oid.create() 22 | print(mongo.oid.time(oid)) 23 | } 24 | \seealso{ 25 | \link{mongo.oid},\cr \code{\link{mongo.oid.create}},\cr 26 | \code{\link{as.character.mongo.oid}},\cr 27 | \code{\link{mongo.oid.to.string}},\cr 28 | \code{\link{mongo.oid.from.string}},\cr 29 | \code{\link{mongo.bson.buffer.append}},\cr 30 | \code{\link{mongo.bson.buffer.append.oid}},\cr \link{mongo.bson.buffer},\cr 31 | \link{mongo.bson}. 32 | } 33 | 34 | -------------------------------------------------------------------------------- /man/mongo.drop.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.drop} 3 | \alias{mongo.drop} 4 | \title{Drop a collection from a MongoDB server} 5 | \usage{ 6 | mongo.drop(mongo, ns) 7 | } 8 | \arguments{ 9 | \item{mongo}{(\link{mongo}) A mongo connection object.} 10 | 11 | \item{ns}{(string) The namespace of the collection to drop.} 12 | } 13 | \value{ 14 | (Logical) TRUE if successful; otherwise, FALSE 15 | } 16 | \description{ 17 | Drop a collection from a database on MongoDB server. This removes the 18 | entire collection. 19 | } 20 | \details{ 21 | Obviously, care should be taken when using this command. 22 | } 23 | \examples{ 24 | mongo <- mongo.create() 25 | if (mongo.is.connected(mongo)) { 26 | print(mongo.drop(mongo, "test.people")) 27 | 28 | mongo.destroy(mongo) 29 | } 30 | } 31 | \seealso{ 32 | \code{\link{mongo.drop.database}},\cr 33 | \code{\link{mongo.command}},\cr \code{\link{mongo.rename}},\cr 34 | \code{\link{mongo.count}},\cr \link{mongo}. 35 | } 36 | 37 | -------------------------------------------------------------------------------- /man/mongo.shorthand.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.shorthand} 3 | \alias{mongo.shorthand} 4 | \title{Define shorthand for BSON and GridFS} 5 | \usage{ 6 | mongo.shorthand() 7 | } 8 | \value{ 9 | TRUE 10 | } 11 | \description{ 12 | Define shorthand names for BSON and GridFS functions and constants. 13 | } 14 | \details{ 15 | All symbols dealing with BSON and GridFS are defined by this function 16 | excluding the "mongo." prefix. They will still be available by the orginal 17 | names also. For clarity, the symbols in the mongo module (for communication 18 | with the server) are not shortened. 19 | } 20 | \examples{ 21 | mongo.shorthand() 22 | buf <- bson.buffer.create() 23 | bson.buffer.append(buf, "name", "Alice") 24 | b <- bson.from.buffer(buf) 25 | } 26 | \seealso{ 27 | \link{mongo.bson},\cr \link{mongo.gridfs},\cr 28 | \code{\link{mongo.bson.buffer.create}},\cr 29 | \code{\link{mongo.bson.buffer.append}},\cr 30 | \code{\link{mongo.bson.from.buffer}}. 31 | } 32 | 33 | -------------------------------------------------------------------------------- /man/mongo.bson.buffer.append.null.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.buffer.append.null} 3 | \alias{mongo.bson.buffer.append.null} 4 | \title{Append a double field onto a mongo.bson.buffer} 5 | \usage{ 6 | mongo.bson.buffer.append.null(buf, name) 7 | } 8 | \arguments{ 9 | \item{buf}{(\link{mongo.bson.buffer}) The buffer object to which to append.} 10 | 11 | \item{name}{(string) The name (key) of the field appended to the buffer.} 12 | } 13 | \value{ 14 | TRUE if successful; otherwise, FALSE if an error occured appending 15 | the data. 16 | } 17 | \description{ 18 | Append a NULL value onto a \link{mongo.bson.buffer}. 19 | } 20 | \examples{ 21 | buf <- mongo.bson.buffer.create() 22 | mongo.bson.buffer.append.null(buf, "Nil") 23 | b <- mongo.bson.from.buffer(buf) 24 | 25 | # The above produces a BSON object of the form { "Nil" : NULL } 26 | } 27 | \seealso{ 28 | \link{mongo.bson},\cr \link{mongo.bson.buffer},\cr 29 | \code{\link{mongo.bson.buffer.append}}. 30 | } 31 | 32 | -------------------------------------------------------------------------------- /man/mongo.gridfs.destroy.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.gridfs.destroy} 3 | \alias{mongo.gridfs.destroy} 4 | \title{Destroy a mongo.gridfs object} 5 | \usage{ 6 | mongo.gridfs.destroy(gridfs) 7 | } 8 | \arguments{ 9 | \item{gridfs}{A (\link{mongo.gridfs}) object.} 10 | } 11 | \description{ 12 | Releases the resources associated with a \link{mongo.gridfs} object. 13 | } 14 | \details{ 15 | It is not absolutely necessary to call this function since R's garbage 16 | collection will eventually get around to doing it for you. 17 | } 18 | \examples{ 19 | mongo <- mongo.create() 20 | if (mongo.is.connected(mongo)) { 21 | gridfs <- mongo.gridfs.create(mongo, "grid") 22 | # Copy a local file to the server as a gridfs file 23 | mongo.gridfs.store.file(gridfs, "tests/test.R", "test.R") 24 | mongo.gridfs.destroy(gridfs) 25 | } 26 | } 27 | \seealso{ 28 | \link{mongo.gridfs},\cr \code{\link{mongo.gridfs.create}},\cr 29 | \code{\link{mongo.gridfs.store.file}}. 30 | } 31 | 32 | -------------------------------------------------------------------------------- /man/mongo.set.timeout.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.set.timeout} 3 | \alias{mongo.set.timeout} 4 | \title{Set the timeout value on a mongo connection} 5 | \usage{ 6 | mongo.set.timeout(mongo, timeout) 7 | } 8 | \arguments{ 9 | \item{mongo}{(\link{mongo}) a mongo connection object.} 10 | 11 | \item{timeout}{(as.integer) number of milliseconds to which to set the 12 | timeout value.} 13 | } 14 | \description{ 15 | Set the timeout value for network operations on a mongo connection. 16 | Subsequent network operations will timeout if they take longer than the 17 | given number of milliseconds. 18 | } 19 | \examples{ 20 | mongo <- mongo.create() 21 | if (mongo.is.connected(mongo)) { 22 | mongo.set.timeout(mongo, 2000L) 23 | timeout <- mongo.get.timeout(mongo) 24 | if (timeout != 2000L) 25 | error("expected timeout of 2000"); 26 | } 27 | } 28 | \seealso{ 29 | \code{\link{mongo.get.timeout}},\cr \code{\link{mongo.create}},\cr 30 | \link{mongo}. 31 | } 32 | 33 | -------------------------------------------------------------------------------- /man/mongo.drop.database.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.drop.database} 3 | \alias{mongo.drop.database} 4 | \title{Drop a database from a MongoDB server} 5 | \usage{ 6 | mongo.drop.database(mongo, db) 7 | } 8 | \arguments{ 9 | \item{mongo}{(\link{mongo}) A mongo connection object.} 10 | 11 | \item{db}{(string) The name of the database to drop.} 12 | } 13 | \value{ 14 | (Logical) TRUE if successful; otherwise, FALSE 15 | } 16 | \description{ 17 | Drop a database from MongoDB server. Removes the entire database and all 18 | collections in it. 19 | } 20 | \details{ 21 | Obviously, care should be taken when using this command. 22 | } 23 | \examples{ 24 | mongo <- mongo.create() 25 | if (mongo.is.connected(mongo)) { 26 | print(mongo.drop.database(mongo, "test")) 27 | 28 | mongo.destroy(mongo) 29 | } 30 | } 31 | \seealso{ 32 | \code{\link{mongo.drop}},\cr \code{\link{mongo.command}},\cr 33 | \code{\link{mongo.rename}},\cr \code{\link{mongo.count}},\cr \link{mongo}. 34 | } 35 | 36 | -------------------------------------------------------------------------------- /man/mongo.add.user.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.add.user} 3 | \alias{mongo.add.user} 4 | \title{Add a user and password} 5 | \usage{ 6 | mongo.add.user(mongo, username, password, db = "admin") 7 | } 8 | \arguments{ 9 | \item{mongo}{(\link{mongo}) a mongo connection object.} 10 | 11 | \item{username}{(string) username to add.} 12 | 13 | \item{password}{(string) password corresponding to username.} 14 | 15 | \item{db}{(string) The database on the server to which to add the username 16 | and password.} 17 | } 18 | \description{ 19 | Add a user and password to the given database on a MongoDB server for 20 | authentication purposes. 21 | } 22 | \details{ 23 | See \url{http://www.mongodb.org/display/DOCS/Security+and+Authentication}. 24 | } 25 | \examples{ 26 | mongo <- mongo.create() 27 | if (mongo.is.connected(mongo)) 28 | mongo.add.user(mongo, "Jeff", "H87b5dog") 29 | } 30 | \seealso{ 31 | \code{\link{mongo.authenticate}},\cr \link{mongo},\cr 32 | \code{\link{mongo.create}}. 33 | } 34 | 35 | -------------------------------------------------------------------------------- /man/mongo.bson.buffer.append.oid.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.buffer.append.oid} 3 | \alias{mongo.bson.buffer.append.oid} 4 | \title{Append a OID into a mongo.bson.buffer} 5 | \usage{ 6 | mongo.bson.buffer.append.oid(buf, name, value) 7 | } 8 | \arguments{ 9 | \item{buf}{(\link{mongo.bson.buffer}) The buffer object to which to append.} 10 | 11 | \item{name}{(string) The name (key) of the field appended to the buffer.} 12 | 13 | \item{value}{(\link{mongo.oid}) An OID value.} 14 | } 15 | \value{ 16 | TRUE if successful; otherwise, FALSE if an error occured appending 17 | the data. 18 | } 19 | \description{ 20 | Append a OID (Object ID) value into a \link{mongo.bson.buffer}. 21 | } 22 | \examples{ 23 | buf <- mongo.bson.buffer.create() 24 | mongo.bson.buffer.append.oid(buf, "Now", mongo.oid.create()) 25 | b <- mongo.bson.from.buffer(buf) 26 | } 27 | \seealso{ 28 | \link{mongo.bson},\cr \link{mongo.bson.buffer},\cr 29 | \link{mongo.oid.create},\cr \code{\link{mongo.bson.buffer.append}}. 30 | } 31 | 32 | -------------------------------------------------------------------------------- /man/mongo.is.master.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.is.master} 3 | \alias{mongo.is.master} 4 | \title{Determine if a mongo connection object is connected to a master} 5 | \usage{ 6 | mongo.is.master(mongo) 7 | } 8 | \arguments{ 9 | \item{mongo}{(\link{mongo}) a mongo connection object.} 10 | } 11 | \value{ 12 | (logical) TRUE if the server reports that it is a master; otherwise, 13 | FALSE. 14 | } 15 | \description{ 16 | Determine if a mongo connection object is connected to a master. Normally, 17 | this is only used with replsets to see if we are currently connected to the 18 | master of the replset. However, when connected to a singleton, this function 19 | reports TRUE also. 20 | } 21 | \examples{ 22 | \dontrun{ 23 | mongo <- mongo.create(c("127.0.0.1", "192.168.0.3"), name="Accounts") 24 | if (mongo.is.connected(mongo)) { 25 | print("isMaster") 26 | print(if (mongo.is.master(mongo)) "Yes" else "No") 27 | } 28 | } 29 | } 30 | \seealso{ 31 | \code{\link{mongo.create}},\cr \link{mongo}. 32 | } 33 | 34 | -------------------------------------------------------------------------------- /man/print.mongo.oid.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{print.mongo.oid} 3 | \alias{print.mongo.oid} 4 | \title{Display a mongo.oid object} 5 | \usage{ 6 | \method{print}{mongo.oid}(x, ...) 7 | } 8 | \arguments{ 9 | \item{x}{\link{mongo.oid} The object to display.} 10 | 11 | \item{...}{Parameters passed from generic.} 12 | } 13 | \value{ 14 | The parameter is returned unchanged. 15 | } 16 | \description{ 17 | Display formatted output of a \link{mongo.oid} object. 18 | } 19 | \details{ 20 | Output is tabbed (indented to show the nesting level of subobjects and 21 | arrays). 22 | 23 | This version is an alias of \code{\link{mongo.oid.print}()} so that 24 | \code{print()} will properly handle the mongo.oid class. 25 | } 26 | \examples{ 27 | oid <- mongo.oid.create() 28 | 29 | # all display the same thing 30 | print.mongo.oid(oid) 31 | mongo.oid.print(oid) 32 | print(oid) 33 | } 34 | \seealso{ 35 | \code{\link{mongo.oid.print}},\cr 36 | \code{\link{mongo.oid.to.string}},\cr \link{mongo.bson.oid},\cr 37 | \link{mongo.bson}. 38 | } 39 | 40 | -------------------------------------------------------------------------------- /man/mongo.bson.dbref.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{data} 3 | \name{mongo.bson.dbref} 4 | \alias{mongo.bson.dbref} 5 | \title{BSON data type constant for a dbref value} 6 | \format{\preformatted{ int 12 7 | }} 8 | \usage{ 9 | mongo.bson.dbref 10 | } 11 | \value{ 12 | 12L 13 | } 14 | \description{ 15 | \code{\link{mongo.bson.iterator.type}()} and 16 | \code{\link{mongo.bson.iterator.next}()} will return this constant (12L) to 17 | indicate that the value pointed to by an iterator is a dbref (database 18 | reference). 19 | } 20 | \details{ 21 | Note that this BSON data type is deprecated and rmongodb provides no support 22 | for it. Attempting to fetch the value of a dbref with 23 | \code{\link{mongo.bson.to.list}()} or\cr 24 | \code{\link{mongo.bson.iterator.value}()} will throw an error. The field 25 | must be skipped by calling \code{\link{mongo.bson.iterator.next}()}. 26 | } 27 | \seealso{ 28 | \code{\link{mongo.bson.iterator.type}},\cr 29 | \code{\link{mongo.bson.iterator.next}},\cr \link{mongo.bson}. 30 | } 31 | \keyword{datasets} 32 | 33 | -------------------------------------------------------------------------------- /man/mongo.rename.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.rename} 3 | \alias{mongo.rename} 4 | \title{Rename a collection on a MongoDB server} 5 | \usage{ 6 | mongo.rename(mongo, from.ns, to.ns) 7 | } 8 | \arguments{ 9 | \item{mongo}{(\link{mongo}) A mongo connection object.} 10 | 11 | \item{from.ns}{(string) The namespace of the collection to rename.} 12 | 13 | \item{to.ns}{(string) The new namespace of the collection.} 14 | } 15 | \value{ 16 | TRUE if successful; otherwise, FALSE. 17 | } 18 | \description{ 19 | Rename a collection on a MongoDB server. 20 | } 21 | \details{ 22 | Note that this may also be used to move a collection from one database to 23 | another. 24 | } 25 | \examples{ 26 | mongo <- mongo.create() 27 | if (mongo.is.connected(mongo)) { 28 | print(mongo.rename(mongo, "test.people", "test.humans")) 29 | 30 | mongo.destroy(mongo) 31 | } 32 | } 33 | \seealso{ 34 | \code{\link{mongo.drop.database}},\cr \code{\link{mongo.drop}},\cr 35 | \code{\link{mongo.command}},\cr \code{\link{mongo.count}},\cr \link{mongo}. 36 | } 37 | 38 | -------------------------------------------------------------------------------- /man/print.mongo.bson.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{print.mongo.bson} 3 | \alias{print.mongo.bson} 4 | \title{Display a mongo.bson object} 5 | \usage{ 6 | \method{print}{mongo.bson}(x, ...) 7 | } 8 | \arguments{ 9 | \item{x}{(\link{mongo.bson} The object to display.} 10 | 11 | \item{...}{Parameters passed from generic.} 12 | } 13 | \value{ 14 | The parameter is returned unchanged. 15 | } 16 | \description{ 17 | Display formatted output of a mongo.bson object. 18 | } 19 | \details{ 20 | Output is tabbed (indented to show the nesting level of subobjects and 21 | arrays). 22 | 23 | This version is an alias of mongo.bson.print() so that print() will properly 24 | handle the mongo.bson class. 25 | } 26 | \examples{ 27 | buf <- mongo.bson.buffer.create() 28 | mongo.bson.buffer.append(buf, "name", "Fred") 29 | mongo.bson.buffer.append(buf, "city", "Dayton") 30 | b <- mongo.bson.from.buffer(buf) 31 | 32 | # all display the same thing 33 | print.mongo.bson(b) 34 | mongo.bson.print(b) 35 | print(b) 36 | } 37 | \seealso{ 38 | \code{\link{mongo.bson.print}},\cr \link{mongo.bson}. 39 | } 40 | 41 | -------------------------------------------------------------------------------- /man/mongo.bson.iterator.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{class} 3 | \name{mongo.bson.iterator} 4 | \alias{mongo.bson.iterator} 5 | \title{The mongo.bson.iterator class} 6 | \description{ 7 | Objects of class "mongo.bson.iterator" are used to iterate through BSON 8 | documents as stored in \link{mongo.bson} objects. 9 | } 10 | \details{ 11 | mongo.bson.iterator objects have "mongo.bson.iterator" as their class and 12 | contain an externally managed pointer to the actual document data. This 13 | pointer is stored in the "mongo.bson.iterator" attribute of the object. 14 | } 15 | \examples{ 16 | b <- mongo.bson.from.list(list(name="Joy", age=35, city="Ontario")) 17 | # b is of class "mongo.bson" 18 | iter <- mongo.bson.iterator.create(b) 19 | while (mongo.bson.iterator.next(iter)) 20 | print(mongo.bson.iterator.value(iter)) 21 | } 22 | \seealso{ 23 | \code{\link{mongo.bson.iterator.create}},\cr 24 | \code{\link{mongo.bson.find}},\cr \code{\link{mongo.bson.iterator.next}},\cr 25 | \code{\link{mongo.bson.iterator.key}},\cr 26 | \code{\link{mongo.bson.iterator.value}},\cr \link{mongo.bson}. 27 | } 28 | 29 | -------------------------------------------------------------------------------- /src/utility.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2008-2011 10gen Inc. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | */ 15 | #include 16 | #include "libmongo/bson.h" 17 | #include "libmongo/mongo.h" 18 | 19 | int _hasClass(SEXP cls, const char* name); 20 | int _objHasClass(SEXP b, const char* name); 21 | void _checkClass(SEXP b, const char* name); 22 | int _isBSON(SEXP b); 23 | bson* _checkBSON(SEXP b); 24 | mongo* _checkMongo(SEXP mongo_conn); 25 | SEXP _mongo_bson_create(bson* b); 26 | SEXP _createPOSIXct(double t); 27 | SEXP _mongo_cursor_create(mongo_cursor* cursor); 28 | -------------------------------------------------------------------------------- /man/mongo.bson.buffer.size.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.buffer.size} 3 | \alias{mongo.bson.buffer.size} 4 | \title{Get the size of a mongo.bson.buffer object} 5 | \usage{ 6 | mongo.bson.buffer.size(buf) 7 | } 8 | \arguments{ 9 | \item{buf}{(\link{mongo.bson.buffer}) the mongo.bson.buffer object to 10 | examine.} 11 | } 12 | \value{ 13 | (integer) the number of bytes which would be taken up by the BSON 14 | data with the buffer is converted to a mongo.bson object with 15 | \code{\link{mongo.bson.from.buffer}()}. 16 | } 17 | \description{ 18 | Get the number of bytes which would be taken up by the BSON data when the 19 | buffer is converted to a mongo.bson object with 20 | \code{\link{mongo.bson.from.buffer}()}. 21 | } 22 | \examples{ 23 | buf <- mongo.bson.buffer.create() 24 | mongo.bson.buffer.append(buf, "name", "Fred") 25 | mongo.bson.buffer.append(buf, "city", "Dayton") 26 | # both should report 37 27 | print(mongo.bson.buffer.size(buf)) 28 | y <- mongo.bson.from.buffer(buf) 29 | print(mongo.bson.size(y)) 30 | } 31 | \seealso{ 32 | \link{mongo.bson.buffer},\cr \link{mongo.bson}. 33 | } 34 | 35 | -------------------------------------------------------------------------------- /man/mongo.bson.from.buffer.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.from.buffer} 3 | \alias{mongo.bson.from.buffer} 4 | \title{Convert a mongo.bson.buffer object to a mongo.bson object} 5 | \usage{ 6 | mongo.bson.from.buffer(buf) 7 | } 8 | \arguments{ 9 | \item{buf}{(\link{mongo.bson.buffer}) The buffer to convert.} 10 | } 11 | \value{ 12 | A \link{mongo.bson} object as converted from the buffer parameter. 13 | } 14 | \description{ 15 | Convert a \link{mongo.bson.buffer} object to a \link{mongo.bson} object. 16 | } 17 | \details{ 18 | Use this after appending data to a buffer to turn it into a mongo.bson 19 | object for network transport. 20 | 21 | No futher data may be appended to the buffer after calling this function. 22 | } 23 | \examples{ 24 | buf <- mongo.bson.buffer.create() 25 | mongo.bson.buffer.append(buf, "name", "Fred") 26 | mongo.bson.buffer.append(buf, "city", "Dayton") 27 | b <- mongo.bson.from.buffer(buf) 28 | print(b) 29 | mongo.bson.destroy(b) 30 | } 31 | \seealso{ 32 | \link{mongo.bson},\cr \link{mongo.bson.buffer},\cr 33 | \code{\link{mongo.bson.buffer.append}},\cr \code{\link{mongo.bson.destroy}}. 34 | } 35 | 36 | -------------------------------------------------------------------------------- /man/mongo.authenticate.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.authenticate} 3 | \alias{mongo.authenticate} 4 | \title{Autherticate a user and password} 5 | \usage{ 6 | mongo.authenticate(mongo, username, password, db = "admin") 7 | } 8 | \arguments{ 9 | \item{mongo}{(\link{mongo}) a mongo connection object.} 10 | 11 | \item{username}{(string) username to authenticate.} 12 | 13 | \item{password}{(string) password corresponding to username.} 14 | 15 | \item{db}{(string) The database on the server against which to validate the 16 | username and password.} 17 | } 18 | \description{ 19 | Autherticate a user and password against a given database on a MongoDB 20 | server. 21 | } 22 | \details{ 23 | See \url{http://www.mongodb.org/display/DOCS/Security+and+Authentication}. 24 | 25 | Note that \code{\link{mongo.create}()} can authenticate a username and 26 | password before returning a connected mongo object. 27 | } 28 | \examples{ 29 | mongo <- mongo.create() 30 | if (mongo.is.connected(mongo)) 31 | mongo.authenticate(mongo, "Joe", "ZxYaBc217") 32 | } 33 | \seealso{ 34 | \code{\link{mongo.add.user}},\cr 35 | \code{\link{mongo.create}}. 36 | } 37 | 38 | -------------------------------------------------------------------------------- /man/mongo.destroy.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.destroy} 3 | \alias{mongo.destroy} 4 | \title{Destroy a MongoDB connection} 5 | \usage{ 6 | mongo.destroy(mongo) 7 | } 8 | \arguments{ 9 | \item{mongo}{(\link{mongo}) a mongo connection object.} 10 | } 11 | \description{ 12 | Destroy a \link{mongo} connection. The connection is disconnected first if 13 | it is still connected. No further communication is possible on the 14 | connection. Releases resources attached to the connection on both client 15 | and server. 16 | } 17 | \details{ 18 | Although the 'destroy' functions in this package are called automatically by 19 | garbage collection, this one in particular should be called as soon as 20 | feasible when finished with the connection so that server resources are 21 | freed. 22 | } 23 | \examples{ 24 | mongo <- mongo.create() 25 | if (mongo.is.connected(mongo)) { 26 | n_people <- mongo.count(mongo, "test.people") 27 | mongo.destroy(mongo) 28 | print(n_people) 29 | } 30 | } 31 | \seealso{ 32 | \link{mongo},\cr \code{\link{mongo.disconnect}},\cr 33 | \code{\link{mongo.is.connected}}\cr \code{\link{mongo.reconnect}}. 34 | } 35 | 36 | -------------------------------------------------------------------------------- /tests/test_errors.R: -------------------------------------------------------------------------------- 1 | library(rmongodb) 2 | library(RUnit) 3 | 4 | # 5 tests 5 | # 22.11.2013 6 | 7 | # set up mongoDB connection and db / collection parameters 8 | mongo <- mongo.create() 9 | db <- "rmongodb" 10 | ns <- paste(db, "test_errors", sep=".") 11 | 12 | if( mongo.is.connected(mongo) ){ 13 | 14 | # clean up old existing collection 15 | mongo.drop(mongo, ns) 16 | 17 | mongo.insert(mongo, ns, mongo.bson.from.JSON('{"$or":2}') ) 18 | err <- mongo.get.last.err(mongo, db) 19 | print(mongo.get.server.err(mongo)) 20 | checkEquals( class(err), "mongo.bson") 21 | 22 | iter <- mongo.bson.find(err, "code") 23 | print(mongo.bson.iterator.value(iter)) 24 | checkTrue( is.integer(iter) ) 25 | 26 | err_str <- mongo.get.server.err.string(mongo) 27 | print(err_str) 28 | checkTrue( is.character(err_str) ) 29 | 30 | iter <- mongo.bson.find(err, "err") 31 | err_str <- mongo.bson.iterator.value(iter) 32 | print(err_str) 33 | checkTrue( is.character(err_str) ) 34 | 35 | out <- mongo.reset.err(mongo, db) 36 | checkTrue( is.null( out ) ) 37 | 38 | # cleanup db and close connection 39 | mongo.drop.database(mongo, db) 40 | mongo.destroy(mongo) 41 | } -------------------------------------------------------------------------------- /man/mongo.bson.from.df.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.from.df} 3 | \alias{mongo.bson.from.df} 4 | \title{Convert a data.frame to a mongo.bson object} 5 | \usage{ 6 | mongo.bson.from.df(df) 7 | } 8 | \arguments{ 9 | \item{df}{(data.frame) The data.frame to convert. 10 | 11 | This \emph{must} be a data.frame, \emph{not} a vector of atomic types; otherwise, 12 | an error is thrown; use \code{as.data.frame()} as necessary.} 13 | } 14 | \value{ 15 | (\link{mongo.bson}) A mongo.bson object serialized from \code{data.frame}. 16 | } 17 | \description{ 18 | Convert a data.frame to a \link{mongo.bson} object. 19 | } 20 | \details{ 21 | This function permits the simple and convenient creation of a mongo.bson 22 | object. This bypasses the creation of a \link{mongo.bson.buffer}, appending 23 | fields one by one, and then turning the buffer into a mongo.bson object with 24 | \code{\link{mongo.bson.from.buffer}()}. 25 | } 26 | \examples{ 27 | df <- data.frame(name=c("John", "Peter"), age=c(32,18)) 28 | b <- mongo.bson.from.df(df) 29 | } 30 | \seealso{ 31 | \code{\link{mongo.bson.to.list}},\cr \link{mongo.bson},\cr 32 | \code{\link{mongo.bson.destroy}}. 33 | } 34 | 35 | -------------------------------------------------------------------------------- /man/mongo.gridfile.destroy.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.gridfile.destroy} 3 | \alias{mongo.gridfile.destroy} 4 | \title{Destroy a mongo.gridfile object} 5 | \usage{ 6 | mongo.gridfile.destroy(gridfile) 7 | } 8 | \arguments{ 9 | \item{gridfile}{A (\link{mongo.gridfile}) object.} 10 | } 11 | \description{ 12 | Releases the resources associated with a \link{mongo.gridfile} object.\cr 13 | These are created by \code{\link{mongo.gridfs.find}()}. 14 | } 15 | \details{ 16 | It is not absolutely necessary to call this function since R's garbage 17 | collection will eventually get around to doing it for you. 18 | } 19 | \examples{ 20 | mongo <- mongo.create() 21 | if (mongo.is.connected(mongo)) { 22 | gridfs <- mongo.gridfs.create(mongo, "grid") 23 | mongo.gridfs.store.file(gridfs, "tests/test.R", "test.R") 24 | gf <- mongo.gridfs.find(gridfs, "test.R") 25 | if( !is.null(gf) ){ 26 | print(mongo.gridfile.get.upload.date(gf)) 27 | mongo.gridfile.destroy(gf) 28 | } 29 | mongo.gridfs.destroy(gridfs) 30 | } 31 | } 32 | \seealso{ 33 | \code{\link{mongo.gridfs.find}},\cr \link{mongo.gridfile},\cr 34 | \link{mongo.gridfs}. 35 | } 36 | 37 | -------------------------------------------------------------------------------- /man/mongo.undefined.create.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.undefined.create} 3 | \alias{mongo.undefined.create} 4 | \title{Create a mongo.undefined object} 5 | \usage{ 6 | mongo.undefined.create() 7 | } 8 | \value{ 9 | a \link{mongo.undefined} object 10 | } 11 | \description{ 12 | Create a mongo.undefined object for appending to a buffer with\cr 13 | \code{\link{mongo.bson.buffer.append}()} or for embedding in a list such 14 | that \code{\link{mongo.bson.buffer.append.list}()} will properly insert an 15 | undefined value into the mongo.bson.buffer object. 16 | } 17 | \examples{ 18 | buf <- mongo.bson.buffer.create() 19 | undef <- mongo.undefined.create() 20 | mongo.bson.buffer.append(buf, "Undef", undef) 21 | l <- list(u1 = undef, One = 1) 22 | mongo.bson.buffer.append.list(buf, "listWundef", l) 23 | b <- mongo.bson.from.buffer(buf) 24 | 25 | # the above will create a mongo.bson object of the following form: 26 | # { "Undef": UNDEFINED, "listWundef" : { "u1" : UNDEFINED, "One" : 1 } } 27 | } 28 | \seealso{ 29 | \link{mongo.undefined},\cr 30 | \code{\link{mongo.bson.buffer.append}},\cr 31 | \code{\link{mongo.bson.buffer.append.list}},\cr \link{mongo.bson.buffer},\cr 32 | \link{mongo.bson}. 33 | } 34 | 35 | -------------------------------------------------------------------------------- /man/mongo.bson.buffer.append.regex.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.buffer.append.regex} 3 | \alias{mongo.bson.buffer.append.regex} 4 | \title{Append a timestamp value into a mongo.bson.buffer} 5 | \usage{ 6 | mongo.bson.buffer.append.regex(buf, name, value) 7 | } 8 | \arguments{ 9 | \item{buf}{(\link{mongo.bson.buffer}) The buffer object to which to append.} 10 | 11 | \item{name}{(string) The name (key) of the field appended to the buffer.} 12 | 13 | \item{value}{(\link{mongo.regex}) A regular expression as created\cr by 14 | \code{\link{mongo.regex.create}()}.} 15 | } 16 | \value{ 17 | TRUE if successful; otherwise, FALSE if an error occured appending 18 | the data. 19 | } 20 | \description{ 21 | Append a regular expression value into a \link{mongo.bson.buffer}. 22 | } 23 | \examples{ 24 | buf <- mongo.bson.buffer.create() 25 | regex <- mongo.regex.create("acme.*corp", options="i") 26 | mongo.bson.buffer.append.regex(buf, "MatchAcme", regex) 27 | b <- mongo.bson.from.buffer(buf) 28 | } 29 | \seealso{ 30 | \link{mongo.regex.create},\cr 31 | \code{\link{mongo.bson.buffer.append.regex}},\cr 32 | \code{\link{mongo.bson.buffer.append}},\cr \link{mongo.bson},\cr 33 | \link{mongo.bson.buffer}. 34 | } 35 | 36 | -------------------------------------------------------------------------------- /man/mongo.get.database.collections.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.get.database.collections} 3 | \alias{mongo.get.database.collections} 4 | \title{Get a list of collections in a database} 5 | \usage{ 6 | mongo.get.database.collections(mongo, db) 7 | } 8 | \arguments{ 9 | \item{mongo}{(\link{mongo}) A mongo connection object.} 10 | 11 | \item{db}{(string) Name of the database for which to get the list of 12 | collections.} 13 | } 14 | \value{ 15 | (string vector) List of collection namespaces in the given database. 16 | 17 | Note this will not include the system collection \code{db}.system.indexes 18 | nor the indexes attached to the database. Use \code{mongo.find(mongo, 19 | "db.system.indexes", limit=0L)} for information on any indexes. 20 | } 21 | \description{ 22 | Get a list of collections in a database on a MongoDB server. 23 | } 24 | \examples{ 25 | mongo <- mongo.create() 26 | if (mongo.is.connected(mongo)) { 27 | print(mongo.get.database.collections(mongo, "test")) 28 | 29 | mongo.destroy(mongo) 30 | } 31 | } 32 | \seealso{ 33 | \code{\link{mongo.get.databases}},\cr 34 | \code{\link{mongo.drop.database}},\cr \code{\link{mongo.drop}},\cr 35 | \code{\link{mongo.command}},\cr \code{\link{mongo.rename}},\cr \link{mongo}. 36 | } 37 | 38 | -------------------------------------------------------------------------------- /man/mongo.regex.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{class} 3 | \name{mongo.regex} 4 | \alias{mongo.regex} 5 | \title{The mongo.regex class} 6 | \description{ 7 | Objects of class "mongo.regex" represent regular expressions and are strings 8 | with the options value stored in the "options" attribute. 9 | } 10 | \details{ 11 | See 12 | \url{http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-RegularExpressions} 13 | 14 | mongo.regex objects have "mongo.regex" as their class so that\cr 15 | \code{\link{mongo.bson.buffer.append}()} may detect them and append the 16 | appropriate BSON regex-typed value to a buffer. 17 | 18 | These mongo.regex values may also be present in a list and will be handled 19 | properly\cr by \code{\link{mongo.bson.buffer.append.list}()} and 20 | \code{\link{mongo.bson.from.list}()}. 21 | } 22 | \examples{ 23 | buf <- mongo.bson.buffer.create() 24 | regex <- mongo.regex.create("acme.*corp", options="i") 25 | mongo.bson.buffer.append.regex(buf, "MatchAcme", regex) 26 | b <- mongo.bson.from.buffer(buf) 27 | } 28 | \seealso{ 29 | \code{\link{mongo.regex.create}},\cr 30 | \code{\link{mongo.bson.buffer.append}},\cr 31 | \code{\link{mongo.bson.buffer.append.list}},\cr \link{mongo.bson.buffer},\cr 32 | \link{mongo.bson}. 33 | } 34 | 35 | -------------------------------------------------------------------------------- /man/mongo.oid.create.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.oid.create} 3 | \alias{mongo.oid.create} 4 | \title{Create a mongo.oid object} 5 | \usage{ 6 | mongo.oid.create() 7 | } 8 | \value{ 9 | A \link{mongo.oid} object that is reasonably assured of being 10 | unique. 11 | } 12 | \description{ 13 | Create a \link{mongo.oid} object for appending to a buffer with\cr 14 | \code{\link{mongo.bson.buffer.append.oid}()} or 15 | \code{\link{mongo.bson.buffer.append}()}, or for embedding in a list such 16 | that \code{\link{mongo.bson.buffer.append.list}()} will properly insert an 17 | Object ID value into a mongo.bson.buffer object. 18 | } 19 | \details{ 20 | See \url{http://www.mongodb.org/display/DOCS/Object+IDs} 21 | } 22 | \examples{ 23 | buf <- mongo.bson.buffer.create() 24 | oid <- mongo.oid.create() 25 | mongo.bson.buffer.append(buf, "_id", oid) 26 | b <- mongo.bson.from.buffer(buf) 27 | } 28 | \seealso{ 29 | \link{mongo.oid},\cr \code{\link{mongo.oid.from.string}},\cr 30 | \code{\link{as.character.mongo.oid}},\cr 31 | \code{\link{mongo.oid.to.string}},\cr 32 | \code{\link{mongo.bson.buffer.append}},\cr 33 | \code{\link{mongo.bson.buffer.append.oid}},\cr 34 | \code{\link{mongo.bson.buffer.append.list}},\cr \link{mongo.bson.buffer},\cr 35 | \link{mongo.bson}. 36 | } 37 | 38 | -------------------------------------------------------------------------------- /man/mongo.distinct.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.distinct} 3 | \alias{mongo.distinct} 4 | \alias{mongo.get.values} 5 | \title{Get a vector of distinct values for keys in a collection} 6 | \usage{ 7 | mongo.distinct(mongo, ns, key, query = mongo.bson.empty()) 8 | } 9 | \arguments{ 10 | \item{mongo}{(\link{mongo}) A mongo connection object.} 11 | 12 | \item{ns}{(string) The namespace of the collection in which to find distinct 13 | keys.} 14 | 15 | \item{key}{(string) The name of the key field for which to get distinct 16 | values.} 17 | 18 | \item{query}{\link{mongo.bson} An optional query to restrict the returned 19 | values.} 20 | } 21 | \value{ 22 | vector of distinct values or NULL if the command failed. 23 | 24 | (vector) The result set of distinct keys. 25 | } 26 | \description{ 27 | Get a vector of distinct values for keys in a collection. 28 | } 29 | \details{ 30 | See 31 | \url{http://www.mongodb.org/display/DOCS/Aggregation#Aggregation-Distinct}. 32 | } 33 | \examples{ 34 | mongo <- mongo.create() 35 | if (mongo.is.connected(mongo)) { 36 | keys <- mongo.distinct(mongo, "test.people", "name") 37 | print(keys) 38 | } 39 | } 40 | \seealso{ 41 | \code{\link{mongo.command}},\cr 42 | \code{\link{mongo.simple.command}},\cr \code{\link{mongo.find}},\cr 43 | \link{mongo}. 44 | } 45 | 46 | -------------------------------------------------------------------------------- /src/symbols.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2008-2011 10gen Inc. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | */ 15 | #include 16 | 17 | void install_mongo_symbols(); 18 | 19 | extern SEXP sym_as_POSIXct; 20 | extern SEXP sym_mongo; 21 | extern SEXP sym_host; 22 | extern SEXP sym_name; 23 | extern SEXP sym_username; 24 | extern SEXP sym_timeout; 25 | extern SEXP sym_mongo_bson; 26 | extern SEXP sym_mongo_bson_buffer; 27 | extern SEXP sym_mongo_bson_iterator; 28 | extern SEXP sym_mongo_oid; 29 | extern SEXP sym_increment; 30 | extern SEXP sym_scope; 31 | extern SEXP sym_mongo_cursor; 32 | extern SEXP sym_options; 33 | extern SEXP sym_subtype; 34 | extern SEXP sym_length; 35 | extern SEXP sym_mongo_gridfs; 36 | extern SEXP sym_mongo_gridfile; 37 | extern SEXP sym_mongo_gridfile_writer; 38 | -------------------------------------------------------------------------------- /man/mongo.oid.to.string.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.oid.to.string} 3 | \alias{mongo.oid.to.string} 4 | \title{Convert a mongo.oid object to a string} 5 | \usage{ 6 | mongo.oid.to.string(oid) 7 | } 8 | \arguments{ 9 | \item{oid}{(\link{mongo.oid}) The OID to be converted.} 10 | } 11 | \value{ 12 | (string) A string of 24 hex digits representing the bits of 13 | \code{oid}. 14 | } 15 | \description{ 16 | Convert a \link{mongo.oid} object to a string of 24 hex digits. This 17 | performs the inverse operation of \code{\link{mongo.oid.from.string}()}. 18 | } 19 | \details{ 20 | This function is an alias of \code{\link{as.character.mongo.oid}()} which 21 | you may perfer to use since the class mechanism of R allows that to be 22 | called simply by \code{as.character(oid)}. 23 | 24 | See \url{http://www.mongodb.org/display/DOCS/Object+IDs} 25 | } 26 | \examples{ 27 | oid <- mongo.oid.create() 28 | print(mongo.oid.to.string(oid)) 29 | print(as.character(oid)) # print same thing as above line 30 | } 31 | \seealso{ 32 | \link{mongo.oid},\cr \code{\link{mongo.oid.create}},\cr 33 | \code{\link{as.character.mongo.oid}},\cr 34 | \code{\link{mongo.oid.from.string}},\cr 35 | \code{\link{mongo.bson.buffer.append}},\cr 36 | \code{\link{mongo.bson.buffer.append.oid}},\cr \link{mongo.bson.buffer},\cr 37 | \link{mongo.bson}. 38 | } 39 | 40 | -------------------------------------------------------------------------------- /man/mongo.oid.from.string.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.oid.from.string} 3 | \alias{mongo.oid.from.string} 4 | \title{Create a mongo.oid object ftom a string} 5 | \usage{ 6 | mongo.oid.from.string(hexstr) 7 | } 8 | \arguments{ 9 | \item{hexstr}{(string) 24 hex characters representing the OID. 10 | 11 | Note that although an error is thrown if the length is not 24, no error is 12 | thrown if the characters are not hex digits; you'll get zero bits for the 13 | invalid digits.} 14 | } 15 | \value{ 16 | A \link{mongo.oid} object constructed from hexstr. 17 | } 18 | \description{ 19 | Create from a 24-character hex string a mongo.oid object representing a 20 | MongoDB Object ID. 21 | } 22 | \details{ 23 | See \url{http://www.mongodb.org/display/DOCS/Object+IDs} 24 | } 25 | \examples{ 26 | buf <- mongo.bson.buffer.create() 27 | oid <- mongo.oid.from.string("ABCD1234EFAB5678CDEF9012") 28 | mongo.bson.buffer.append(buf, "_id", oid) 29 | b <- mongo.bson.from.buffer(buf) 30 | } 31 | \seealso{ 32 | \link{mongo.oid},\cr \code{\link{mongo.oid.create}},\cr 33 | \code{\link{as.character.mongo.oid}},\cr 34 | \code{\link{mongo.oid.to.string}},\cr 35 | \code{\link{mongo.bson.buffer.append}},\cr 36 | \code{\link{mongo.bson.buffer.append.oid}},\cr 37 | \code{\link{mongo.bson.buffer.append.list}},\cr \link{mongo.bson.buffer},\cr 38 | \link{mongo.bson}. 39 | } 40 | 41 | -------------------------------------------------------------------------------- /man/mongo.code.create.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.code.create} 3 | \alias{mongo.code.create} 4 | \title{Create a mongo.code object} 5 | \usage{ 6 | mongo.code.create(code) 7 | } 8 | \arguments{ 9 | \item{code}{(string) javascript code} 10 | } 11 | \value{ 12 | A \link{mongo.code} object 13 | } 14 | \description{ 15 | Create a mongo.code object for appending to a buffer with 16 | \code{\link{mongo.bson.buffer.append}()} or for embedding in a list such 17 | that\cr \code{\link{mongo.bson.buffer.append.list}()} will properly insert a 18 | code value into the mongo.bson.buffer object. 19 | } 20 | \examples{ 21 | buf <- mongo.bson.buffer.create() 22 | code <- mongo.code.create("y = x") 23 | mongo.bson.buffer.append(buf, "Code", code) 24 | lst <- list(c1 = code, One = 1) 25 | mongo.bson.buffer.append.list(buf, "listWcode", lst) 26 | mongo.bson.buffer.append.code(buf, "Code2", "a = 1") 27 | b <- mongo.bson.from.buffer(buf) 28 | 29 | # the above will create a mongo.bson object of the following form: 30 | # { "Code": (CODE) "y = x", 31 | # "listWcode" : { "c1" : (CODE) "y = x", 32 | # "One" : 1 }, 33 | # "Code2" : (CODE) "a = 1" } 34 | } 35 | \seealso{ 36 | \link{mongo.code},\cr \code{\link{mongo.bson.buffer.append}},\cr 37 | \code{\link{mongo.bson.buffer.append.list}},\cr \link{mongo.bson.buffer},\cr 38 | \link{mongo.bson}. 39 | } 40 | 41 | -------------------------------------------------------------------------------- /man/as.character.mongo.oid.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{as.character.mongo.oid} 3 | \alias{as.character.mongo.oid} 4 | \title{Convert a mongo.oid object to a string} 5 | \usage{ 6 | \method{as}{character.mongo.oid}(x, ...) 7 | } 8 | \arguments{ 9 | \item{x}{(\link{mongo.oid}) The OID to be converted.} 10 | 11 | \item{...}{Parameters passed from generic.} 12 | } 13 | \value{ 14 | (string) A string of 24 hex digits representing the bits of oid 15 | \code{x}. 16 | } 17 | \description{ 18 | Convert a \link{mongo.oid} object to a string of 24 hex digits. This 19 | performs the inverse operation of \code{\link{mongo.oid.from.string}()}. 20 | } 21 | \details{ 22 | This function is an alias of \code{\link{mongo.oid.to.string}()} so that the 23 | class mechanism of R allows it to be called simply by 24 | \code{as.character(oid)}. 25 | 26 | See \url{http://www.mongodb.org/display/DOCS/Object+IDs} 27 | } 28 | \examples{ 29 | oid <- mongo.oid.create() 30 | print(as.character.mongo.oid(oid)) 31 | print(as.character(oid)) # print same thing as above line 32 | } 33 | \seealso{ 34 | \link{mongo.oid},\cr \code{\link{mongo.oid.create}},\cr 35 | \code{\link{as.character.mongo.oid}},\cr 36 | \code{\link{mongo.oid.to.string}},\cr 37 | \code{\link{mongo.bson.buffer.append}},\cr 38 | \code{\link{mongo.bson.buffer.append.oid}},\cr \link{mongo.bson.buffer},\cr 39 | \link{mongo.bson}. 40 | } 41 | 42 | -------------------------------------------------------------------------------- /man/mongo.bson.buffer.append.list.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.buffer.append.list} 3 | \alias{mongo.bson.buffer.append.list} 4 | \title{Append a list onto a mongo.bson.buffer} 5 | \usage{ 6 | mongo.bson.buffer.append.list(buf, name, value) 7 | } 8 | \arguments{ 9 | \item{buf}{(\link{mongo.bson.buffer}) The buffer object to which to append.} 10 | 11 | \item{name}{(string) The name (key) of the field appended to the buffer.} 12 | 13 | \item{value}{(list) The list to append to the buffer as a subobject.} 14 | } 15 | \value{ 16 | TRUE if successful; otherwise, FALSE if an error occured appending 17 | the data. 18 | } 19 | \description{ 20 | Append a list onto a \link{mongo.bson.buffer}. 21 | } 22 | \details{ 23 | Note that the value parameter must be a true list, not an vector of a single 24 | atomic type. 25 | 26 | Also note that this function is recursive and will append items that are 27 | lists themselves as subobjects. 28 | } 29 | \examples{ 30 | buf <- mongo.bson.buffer.create() 31 | l <- list(fruit = "apple", hasSeeds = TRUE) 32 | mongo.bson.buffer.append.list(buf, "item", l) 33 | b <- mongo.bson.from.buffer(buf) 34 | 35 | # this produces a BSON object of the form: 36 | # { "item" : { "fruit" : "apple", "hasSeeds" : true } } 37 | } 38 | \seealso{ 39 | \link{mongo.bson},\cr \link{mongo.bson.buffer},\cr 40 | \code{\link{mongo.bson.buffer.append}}. 41 | } 42 | 43 | -------------------------------------------------------------------------------- /man/mongo.symbol.create.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.symbol.create} 3 | \alias{mongo.symbol.create} 4 | \title{Create a mongo.symbol object} 5 | \usage{ 6 | mongo.symbol.create(value) 7 | } 8 | \arguments{ 9 | \item{value}{(string) The value of the symbol} 10 | } 11 | \value{ 12 | a \link{mongo.symbol} object 13 | } 14 | \description{ 15 | Create a mongo.symbol object for appending to a buffer with\cr 16 | \code{\link{mongo.bson.buffer.append}()} or for embedding in a list such 17 | that \code{\link{mongo.bson.buffer.append.list}()} will properly insert a 18 | symbol value into the mongo.bson.buffer object. 19 | } 20 | \examples{ 21 | buf <- mongo.bson.buffer.create() 22 | sym <- mongo.symbol.create("Alpha") 23 | mongo.bson.buffer.append(buf, "A", sym) 24 | lst <- list(s1 = sym, One = 1) 25 | mongo.bson.buffer.append.list(buf, "listWsym", lst) 26 | mongo.bson.buffer.append.symbol(buf, "D", "Delta") 27 | b <- mongo.bson.from.buffer(buf) 28 | 29 | # the above will create a mongo.bson object of the following form: 30 | # { "A": (SYMBOL) "Alpha", 31 | # "listWsym" : { "a1" : (SYMBOL) "Aplha", 32 | # "One" : 1 }, 33 | # "D" : (SYMBOL) "Delta" } 34 | } 35 | \seealso{ 36 | \link{mongo.symbol},\cr \code{\link{mongo.bson.buffer.append}},\cr 37 | \code{\link{mongo.bson.buffer.append.list}},\cr \link{mongo.bson.buffer},\cr 38 | \link{mongo.bson}. 39 | } 40 | 41 | -------------------------------------------------------------------------------- /man/mongo.bson.buffer.append.timestamp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.buffer.append.timestamp} 3 | \alias{mongo.bson.buffer.append.timestamp} 4 | \title{Append a timestamp value into a mongo.bson.buffer} 5 | \usage{ 6 | mongo.bson.buffer.append.timestamp(buf, name, value) 7 | } 8 | \arguments{ 9 | \item{buf}{(\link{mongo.bson.buffer}) The buffer object to which to append.} 10 | 11 | \item{name}{(string) The name (key) of the field appended to the buffer.} 12 | 13 | \item{value}{A (\link{mongo.timestamp}) value as created by 14 | \code{\link{mongo.timestamp.create}()}.} 15 | } 16 | \value{ 17 | TRUE if successful; otherwise, FALSE if an error occured appending 18 | the data. 19 | } 20 | \description{ 21 | Append a timestamp value into a \link{mongo.bson.buffer}. 22 | } 23 | \details{ 24 | \link{mongo.timestamp} objects extend the "POSIXct" class to include an 25 | attrubute "increment". 26 | 27 | See \code{\link{mongo.bson.buffer.append.time}()}. 28 | } 29 | \examples{ 30 | buf <- mongo.bson.buffer.create() 31 | mongo.bson.buffer.append.timestamp(buf, "Now-27", 32 | mongo.timestamp.create(Sys.time(), 27)) 33 | b <- mongo.bson.from.buffer(buf) 34 | } 35 | \seealso{ 36 | \link{mongo.timestamp.create},\cr 37 | \code{\link{mongo.bson.buffer.append.time}},\cr 38 | \code{\link{mongo.bson.buffer.append}},\cr \link{mongo.bson},\cr 39 | \link{mongo.bson.buffer}. 40 | } 41 | 42 | -------------------------------------------------------------------------------- /man/mongo.regex.create.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.regex.create} 3 | \alias{mongo.regex.create} 4 | \title{Create a mongo.regex object} 5 | \usage{ 6 | mongo.regex.create(pattern, options = "") 7 | } 8 | \arguments{ 9 | \item{pattern}{(string) The regular expression.} 10 | 11 | \item{options}{(string) Options governing the parsing done with the pattern.} 12 | } 13 | \value{ 14 | A \link{mongo.regex} object 15 | } 16 | \description{ 17 | Create a \link{mongo.regex} object for appending to a buffer with\cr 18 | \code{\link{mongo.bson.buffer.append.regex}()} or 19 | \code{\link{mongo.bson.buffer.append}()}, or for embedding in a list such 20 | that \code{\link{mongo.bson.buffer.append.list}()} will properly insert a 21 | regular expression value into a mongo.bson.buffer object. 22 | } 23 | \details{ 24 | See 25 | \url{http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-RegularExpressions} 26 | } 27 | \examples{ 28 | buf <- mongo.bson.buffer.create() 29 | regex <- mongo.regex.create("acme.*corp", options="i") 30 | mongo.bson.buffer.append.regex(buf, "MatchAcme", regex) 31 | b <- mongo.bson.from.buffer(buf) 32 | } 33 | \seealso{ 34 | \link{mongo.regex},\cr \code{\link{mongo.bson.buffer.append}},\cr 35 | \code{\link{mongo.bson.buffer.append.regex}},\cr 36 | \code{\link{mongo.bson.buffer.append.list}},\cr \link{mongo.bson.buffer},\cr 37 | \link{mongo.bson}. 38 | } 39 | 40 | -------------------------------------------------------------------------------- /man/mongo.cursor.next.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.cursor.next} 3 | \alias{mongo.cursor.next} 4 | \title{Advance a cursor to the next record} 5 | \usage{ 6 | mongo.cursor.next(cursor) 7 | } 8 | \arguments{ 9 | \item{cursor}{(\link{mongo.cursor}) A mongo.cursor object returned from 10 | \code{\link{mongo.find}()}.} 11 | } 12 | \value{ 13 | TRUE if there is a next record; otherwise, FALSE. 14 | } 15 | \description{ 16 | \code{\link{mongo.cursor.next}(cursor)} is used to step to the first or next 17 | record. 18 | } 19 | \details{ 20 | \code{\link{mongo.cursor.value}(cursor)} may then be used to examine it. 21 | } 22 | \examples{ 23 | mongo <- mongo.create() 24 | if (mongo.is.connected(mongo)) { 25 | buf <- mongo.bson.buffer.create() 26 | mongo.bson.buffer.append(buf, "city", "St. Louis") 27 | query <- mongo.bson.from.buffer(buf) 28 | 29 | # Find the first 1000 records in collection people 30 | # of database test where city == "St. Louis" 31 | cursor <- mongo.find(mongo, "test.people", query, limit=1000L) 32 | # Step though the matching records and display them 33 | while (mongo.cursor.next(cursor)) 34 | print(mongo.cursor.value(cursor)) 35 | mongo.cursor.destroy(cursor) 36 | } 37 | } 38 | \seealso{ 39 | \code{\link{mongo.find}},\cr \link{mongo.cursor},\cr 40 | \code{\link{mongo.cursor.value}},\cr \code{\link{mongo.cursor.destroy}}. 41 | } 42 | 43 | -------------------------------------------------------------------------------- /src/libmongo/env.h: -------------------------------------------------------------------------------- 1 | /** @file env.h */ 2 | 3 | /* Copyright 2009-2012 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /* Header for generic net.h */ 19 | #ifndef MONGO_ENV_H_ 20 | #define MONGO_ENV_H_ 21 | 22 | #include "mongo.h" 23 | 24 | MONGO_EXTERN_C_START 25 | 26 | /* This is a no-op in the generic implementation. */ 27 | int mongo_env_set_socket_op_timeout( mongo *conn, int millis ); 28 | int mongo_env_read_socket( mongo *conn, void *buf, int len ); 29 | int mongo_env_write_socket( mongo *conn, const void *buf, int len ); 30 | int mongo_env_socket_connect( mongo *conn, const char *host, int port ); 31 | 32 | /* Initialize socket services */ 33 | MONGO_EXPORT int mongo_env_sock_init( void ); 34 | 35 | /* Close a socket */ 36 | MONGO_EXPORT int mongo_env_close_socket( int socket ); 37 | 38 | MONGO_EXTERN_C_END 39 | #endif 40 | -------------------------------------------------------------------------------- /man/mongo.cursor.value.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.cursor.value} 3 | \alias{mongo.cursor.value} 4 | \title{Fetch the current value of a cursor} 5 | \usage{ 6 | mongo.cursor.value(cursor) 7 | } 8 | \arguments{ 9 | \item{cursor}{(\link{mongo.cursor}) A mongo.cursor object returned from 10 | \code{\link{mongo.find}()}.} 11 | } 12 | \value{ 13 | (\link{mongo.bson}) The current record of the result set. 14 | } 15 | \description{ 16 | \code{\link{mongo.cursor.value}(cursor)} is used to fetch the current record 17 | belonging to a\cr \code{\link{mongo.find}()} query. 18 | } 19 | \examples{ 20 | mongo <- mongo.create() 21 | if (mongo.is.connected(mongo)) { 22 | buf <- mongo.bson.buffer.create() 23 | mongo.bson.buffer.append(buf, "city", "St. Louis") 24 | query <- mongo.bson.from.buffer(buf) 25 | 26 | # Find the first 1000 records in collection people 27 | # of database test where city == "St. Louis" 28 | cursor <- mongo.find(mongo, "test.people", query, limit=1000L) 29 | # Step though the matching records and display them 30 | while (mongo.cursor.next(cursor)) 31 | print(mongo.cursor.value(cursor)) 32 | mongo.cursor.destroy(cursor) 33 | } 34 | } 35 | \seealso{ 36 | \code{\link{mongo.find}},\cr \code{\link{mongo.cursor}},\cr 37 | \code{\link{mongo.cursor.next}},\cr \code{\link{mongo.cursor.value}},\cr 38 | \code{\link{mongo.cursor.destroy}},\cr \link{mongo.bson}. 39 | } 40 | 41 | -------------------------------------------------------------------------------- /man/mongo.bson.iterator.key.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.iterator.key} 3 | \alias{mongo.bson.iterator.key} 4 | \title{Return the key (name) of the field pointed to by an iterator} 5 | \usage{ 6 | mongo.bson.iterator.key(iter) 7 | } 8 | \arguments{ 9 | \item{iter}{A \link{mongo.bson.iterator}.} 10 | } 11 | \value{ 12 | (string) The key (name) of the field pointed to by \code{iter} 13 | } 14 | \description{ 15 | Return the key (name) of the field pointed to by a 16 | \link{mongo.bson.iterator}. 17 | } 18 | \examples{ 19 | buf <- mongo.bson.buffer.create() 20 | # Append a string 21 | mongo.bson.buffer.append(buf, "name", "Joe") 22 | # Append a date/time 23 | mongo.bson.buffer.append(buf, "created", Sys.time()) 24 | # Append a NULL 25 | mongo.bson.buffer.append(buf, "cars", NULL) 26 | b <- mongo.bson.from.buffer(buf) 27 | 28 | # iterate through all values and print them with their keys (names) 29 | iter <- mongo.bson.iterator.create(b) 30 | while (mongo.bson.iterator.next(iter)) { # eoo at end stops loop 31 | print(mongo.bson.iterator.key(iter)) 32 | print(mongo.bson.iterator.value(iter)) 33 | } 34 | } 35 | \seealso{ 36 | \link{mongo.bson.iterator},\cr 37 | \code{\link{mongo.bson.iterator.create}},\cr 38 | \code{\link{mongo.bson.find}},\cr \code{\link{mongo.bson.iterator.next}},\cr 39 | \code{\link{mongo.bson.iterator.type}},\cr 40 | \code{\link{mongo.bson.iterator.value}},\cr \link{mongo.bson}. 41 | } 42 | 43 | -------------------------------------------------------------------------------- /man/mongo.gridfile.writer.finish.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.gridfile.writer.finish} 3 | \alias{mongo.gridfile.writer.finish} 4 | \title{Finish writing to a buffered GridFS file} 5 | \usage{ 6 | mongo.gridfile.writer.finish(gfw) 7 | } 8 | \arguments{ 9 | \item{gfw}{A (\link{mongo.gridfile.writer}) object.} 10 | } 11 | \value{ 12 | TRUE, if successfil; false, if an error occurred. 13 | } 14 | \description{ 15 | Finish writing to a buffered GridFS file. This function flushes any partial 16 | buffer and finalizes the operation. 17 | } 18 | \examples{ 19 | mongo <- mongo.create() 20 | if (mongo.is.connected(mongo)) { 21 | gridfs <- mongo.gridfs.create(mongo, "grid") 22 | 23 | gfw <- mongo.gridfile.writer.create(gridfs, "test.dat") 24 | 25 | # store 4 bytes 26 | mongo.gridfile.writer.write(gfw, charToRaw("test")) 27 | 28 | # store string & LF plus 0-byte terminator 29 | buf <- writeBin("Test\\n", as.raw(1)) 30 | mongo.gridfile.writer.write(gfw, buf) 31 | 32 | # store PI as a float 33 | buf <- writeBin(3.1415926, as.raw(1), size=4, endian="little") 34 | mongo.gridfile.writer.write(gfw, buf) 35 | 36 | mongo.gridfile.writer.finish(gfw) 37 | mongo.gridfs.destroy(gridfs) 38 | } 39 | } 40 | \seealso{ 41 | \link{mongo.gridfs},\cr 42 | \code{\link{mongo.gridfile.writer.create}},\cr 43 | \link{mongo.gridfile.writer},\cr \code{\link{mongo.gridfile.writer.write}}. 44 | } 45 | 46 | -------------------------------------------------------------------------------- /man/mongo.gridfs.store.file.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.gridfs.store.file} 3 | \alias{mongo.gridfs.store.file} 4 | \title{Store a file into a GridFS on a MongoDB server} 5 | \usage{ 6 | mongo.gridfs.store.file(gridfs, filename, remotename = "", contenttype = "") 7 | } 8 | \arguments{ 9 | \item{gridfs}{A (\link{mongo.gridfs}) object.} 10 | 11 | \item{filename}{(string) The path/filename of the file to copy to the 12 | server.} 13 | 14 | \item{remotename}{(string) The name the file will be known as within the 15 | GridFS.\cr If remotename=="" (the default), the remote file will be known by 16 | the given \code{filename}.} 17 | 18 | \item{contenttype}{(string) Optional MIME content type.} 19 | } 20 | \value{ 21 | TRUE, if successful; FALSE, if an error occured during the 22 | operation. 23 | } 24 | \description{ 25 | Store a file into a GridFS on a MongoDB server. This function stores the 26 | entire given file on the server, breaking it up into 256K chunks as 27 | necessary. 28 | } 29 | \examples{ 30 | mongo <- mongo.create() 31 | if (mongo.is.connected(mongo)) { 32 | gridfs <- mongo.gridfs.create(mongo, "grid") 33 | # Copy a local file to the server as a gridfs file 34 | mongo.gridfs.store.file(gridfs, "tests/test.R", "test.R") 35 | mongo.gridfs.destroy(gridfs) 36 | } 37 | } 38 | \seealso{ 39 | \link{mongo.gridfs},\cr \code{\link{mongo.gridfs.create}},\cr 40 | \code{\link{mongo.gridfs.remove.file}}. 41 | } 42 | 43 | -------------------------------------------------------------------------------- /man/mongo.oid.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{class} 3 | \name{mongo.oid} 4 | \alias{mongo.oid} 5 | \title{The mongo.oid class} 6 | \description{ 7 | Objects of class "mongo.oid" represent MongoDB Object IDs. 8 | } 9 | \details{ 10 | See \url{http://www.mongodb.org/display/DOCS/Object+IDs} 11 | 12 | mongo.oid objects contain an externally managed pointer to the actual 13 | 12-byte object ID data. This pointer is stored in the "mongo.oid" attribute 14 | of the object. 15 | 16 | mongo.oid objects have "mongo.oid" as their class so that 17 | \code{\link{mongo.bson.buffer.append}()} may detect them and append the 18 | appropriate BSON OID-typed value to a buffer. 19 | 20 | mongo.oid values may also be present in a list and will be handled 21 | properly\cr by \code{\link{mongo.bson.buffer.append.list}()} and 22 | \code{\link{mongo.bson.from.list}()}. 23 | } 24 | \examples{ 25 | buf <- mongo.bson.buffer.create() 26 | oid <- mongo.oid.create() 27 | mongo.bson.buffer.append(buf, "_id", oid) 28 | b <- mongo.bson.from.buffer(buf) 29 | } 30 | \seealso{ 31 | \link{mongo.oid},\cr \code{\link{mongo.oid.from.string}},\cr 32 | \code{\link{as.character.mongo.oid}},\cr 33 | \code{\link{mongo.oid.to.string}},\cr \code{\link{mongo.oid.time}},\cr 34 | \code{\link{mongo.bson.buffer.append}},\cr 35 | \code{\link{mongo.bson.buffer.append.oid}},\cr 36 | \code{\link{mongo.bson.buffer.append.list}},\cr \link{mongo.bson.buffer},\cr 37 | \link{mongo.bson}. 38 | } 39 | 40 | -------------------------------------------------------------------------------- /man/mongo.symbol.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{class} 3 | \name{mongo.symbol} 4 | \alias{mongo.symbol} 5 | \title{The mongo.symbol class} 6 | \description{ 7 | Objects of class "mongo.symbol" are used to represent symbol values in BSON 8 | documents. 9 | } 10 | \details{ 11 | mongo.symbol objects' value is a string representing the value of the 12 | symbol. 13 | 14 | mongo.symbol objects have "mongo.symbol" as their class so that\cr 15 | \code{\link{mongo.bson.buffer.append}()} may detect them and append the 16 | appropriate BSON symbol-typed value to a buffer. 17 | 18 | These mongo.symbol values may also be present in a list and will be handled 19 | properly\cr by \code{\link{mongo.bson.buffer.append.list}()} and 20 | \code{\link{mongo.bson.from.list}()}. 21 | } 22 | \examples{ 23 | buf <- mongo.bson.buffer.create() 24 | sym <- mongo.symbol.create("Beta") 25 | mongo.bson.buffer.append(buf, "B", sym) 26 | l <- list(s1 = sym, Two = 2) 27 | mongo.bson.buffer.append.list(buf, "listWsym", l) 28 | b <- mongo.bson.from.buffer(buf) 29 | 30 | # the above will create a mongo.bson object of the following form: 31 | # { "B": (SYMBOL) "Beta", 32 | # "listWsym" : { "s1" : (SYMBOL) "Beta", 33 | # "Two" : 2 } } 34 | } 35 | \seealso{ 36 | \code{\link{mongo.symbol.create}},\cr 37 | \code{\link{mongo.bson.buffer.append}},\cr 38 | \code{\link{mongo.bson.buffer.append.list}},\cr \link{mongo.bson.buffer},\cr 39 | \link{mongo.bson}. 40 | } 41 | 42 | -------------------------------------------------------------------------------- /man/mongo.code.w.scope.create.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.code.w.scope.create} 3 | \alias{mongo.code.w.scope.create} 4 | \title{Create a mongo.code.w.scope object} 5 | \usage{ 6 | mongo.code.w.scope.create(code, scope) 7 | } 8 | \arguments{ 9 | \item{code}{(string) javascript code} 10 | 11 | \item{scope}{(\link{mongo.bson}) the scope object} 12 | } 13 | \value{ 14 | A \link{mongo.code.w.scope} object 15 | } 16 | \description{ 17 | Create a mongo.code.w.scope object for appending to a buffer with\cr 18 | \code{\link{mongo.bson.buffer.append}()} or for embedding in a list such 19 | that \code{\link{mongo.bson.buffer.append.list}()} will properly insert a 20 | code value into the mongo.bson.buffer object. 21 | } 22 | \examples{ 23 | buf <- mongo.bson.buffer.create() 24 | mongo.bson.buffer.append(buf, "scopevar", "scopevalue") 25 | scope <- mongo.bson.from.buffer(buf) 26 | codeWscope <- mongo.code.w.scope.create("y = x", scope) 27 | buf <- mongo.bson.buffer.create() 28 | mongo.bson.buffer.append(buf, "CodeWscope", codeWscope) 29 | b <- mongo.bson.from.buffer(buf) 30 | 31 | # The above produces a BSON object of the form: 32 | # { "CodeWscope" : (CODEWSCOPE) "y = x" 33 | # (SCOPE) { "scopevar" : "scopevalue" } } 34 | } 35 | \seealso{ 36 | \link{mongo.code.w.scope},\cr 37 | \code{\link{mongo.bson.buffer.append}},\cr 38 | \code{\link{mongo.bson.buffer.append.list}},\cr \link{mongo.bson.buffer},\cr 39 | \link{mongo.bson}. 40 | } 41 | 42 | -------------------------------------------------------------------------------- /man/mongo.undefined.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{class} 3 | \name{mongo.undefined} 4 | \alias{mongo.undefined} 5 | \title{The mongo.undefined class} 6 | \description{ 7 | Objects of class "mongo.undefined" are used to represent undefined values in 8 | BSON documents. 9 | } 10 | \details{ 11 | mongo.undefined objects are strings (a character vector) with a single value 12 | of "UNDEFINED" 13 | 14 | mongo.undefined objects have "mongo.undefined" as their class so that\cr 15 | \code{\link{mongo.bson.buffer.append}()} may detect them and append the 16 | appropriate BSON undefined value to a buffer. 17 | 18 | These mongo.undefined values may also be present in a list and will be 19 | handled properly by \code{\link{mongo.bson.buffer.append.list}()} and 20 | \code{\link{mongo.bson.from.list}()}. 21 | } 22 | \examples{ 23 | buf <- mongo.bson.buffer.create() 24 | undef <- mongo.undefined.create() 25 | mongo.bson.buffer.append(buf, "Undef", undef) 26 | l <- list(u1 = undef, One = 1) 27 | mongo.bson.buffer.append.list(buf, "listWundef", l) 28 | b <- mongo.bson.from.buffer(buf) 29 | 30 | # the above will create a mongo.bson object of the following form: 31 | # { "Undef": UNDEFINED, "listWundef" : { "u1" : UNDEFINED, "One" : 1 } } 32 | } 33 | \seealso{ 34 | \code{\link{mongo.undefined.create}},\cr 35 | \code{\link{mongo.bson.buffer.append}},\cr 36 | \code{\link{mongo.bson.buffer.append.list}},\cr \link{mongo.bson.buffer},\cr 37 | \link{mongo.bson}. 38 | } 39 | 40 | -------------------------------------------------------------------------------- /man/mongo.bson.buffer.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{class} 3 | \name{mongo.bson.buffer} 4 | \alias{mongo.bson.buffer} 5 | \title{The mongo.bson.buffer class} 6 | \description{ 7 | Objects of class "mongo.bson.buffer" are used to build BSON documents 8 | (\link{mongo.bson} objects). 9 | } 10 | \details{ 11 | There are many functions for appending data into a mongo.bson.buffer 12 | object.\cr See \code{\link{mongo.bson.buffer.append}()} for a list of those 13 | functions. 14 | 15 | After constructing your object in the buffer, 16 | \code{\link{mongo.bson.from.buffer}()} may be used to turn the buffer into a 17 | mongo.bson object. 18 | 19 | mongo.bson.buffer objects have "mongo.bson.buffer" as their class and 20 | contain an externally managed pointer to the actual document data buffer. 21 | This pointer is stored in the "mongo.bson.buffer" attribute of the object. 22 | } 23 | \examples{ 24 | buf <- mongo.bson.buffer.create() 25 | mongo.bson.buffer.append(buf, "make", "Ford") 26 | mongo.bson.buffer.append(buf, "model", "Mustang") 27 | mongo.bson.buffer.append.int(buf, "year", 1968) 28 | b <- mongo.bson.from.buffer(buf) 29 | } 30 | \seealso{ 31 | \link{mongo.bson},\cr \code{\link{mongo.bson.buffer.size}},\cr 32 | \code{\link{mongo.bson.from.buffer}},\cr 33 | \code{\link{mongo.bson.buffer.append}},\cr 34 | \code{\link{mongo.bson.buffer.start.object}},\cr 35 | \code{\link{mongo.bson.buffer.start.array}},\cr 36 | \code{\link{mongo.bson.buffer.finish.object}}. 37 | } 38 | 39 | -------------------------------------------------------------------------------- /man/mongo.bson.buffer.append.undefined.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.buffer.append.undefined} 3 | \alias{mongo.bson.buffer.append.undefined} 4 | \title{Append a undefined field onto a mongo.bson.buffer} 5 | \usage{ 6 | mongo.bson.buffer.append.undefined(buf, name) 7 | } 8 | \arguments{ 9 | \item{buf}{(\link{mongo.bson.buffer}) The buffer object to which to append.} 10 | 11 | \item{name}{(string) The name (key) of the field appended to the buffer.} 12 | } 13 | \value{ 14 | TRUE if successful; otherwise, FALSE if an error occured appending 15 | the data. 16 | } 17 | \description{ 18 | Append a undefined value onto a \link{mongo.bson.buffer}. 19 | } 20 | \details{ 21 | BSON has a special field type to indicate an undefined value. This function 22 | appends such an indicator as the value of a field. 23 | } 24 | \examples{ 25 | buf <- mongo.bson.buffer.create() 26 | mongo.bson.buffer.append.undefined(buf, "Undef") 27 | b <- mongo.bson.from.buffer(buf) 28 | 29 | # The above produces a BSON object of the form { "Undef" : UNDEFINED } 30 | 31 | # The same result can be produced by the following code: 32 | buf <- mongo.bson.buffer.create() 33 | undef <- mongo.undefined.create() 34 | mongo.bson.buffer.append(buf, "Undef", undef) 35 | b <- mongo.bson.from.buffer(buf) 36 | } 37 | \seealso{ 38 | \link{mongo.bson},\cr \link{mongo.bson.buffer},\cr 39 | \link{mongo.undefined},\cr \code{\link{mongo.undefined.create}},\cr 40 | \code{\link{mongo.bson.buffer.append}}. 41 | } 42 | 43 | -------------------------------------------------------------------------------- /man/mongo.bson.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{class} 3 | \name{mongo.bson} 4 | \alias{mongo.bson} 5 | \title{The mongo.bson class} 6 | \description{ 7 | Objects of class "mongo.bson" are used to store BSON documents. BSON is the 8 | form that MongoDB uses to store documents in its database. MongoDB network 9 | traffic also uses BSON in messages. 10 | } 11 | \details{ 12 | See \url{http://www.mongodb.org/display/DOCS/BSON}. 13 | 14 | mongo.bson objects have "mongo.bson" as their class and contain an 15 | externally managed pointer to the actual document data. This pointer is 16 | stored in the "mongo.bson" attribute of the object. 17 | 18 | Objects of class "\link{mongo.bson.iterator}" are used to iterate over a 19 | mongo.bson object to enumerate its keys and values. 20 | 21 | Objects of class "\link{mongo.bson.buffer}" are used to build BSON 22 | documents. 23 | } 24 | \examples{ 25 | b <- mongo.bson.from.list(list(name="Fred", age=29, city="Boston")) 26 | iter <- mongo.bson.iterator.create(b) # b is of class "mongo.bson" 27 | while (mongo.bson.iterator.next(iter)) 28 | print(mongo.bson.iterator.value(iter)) 29 | } 30 | \seealso{ 31 | \code{\link{mongo.bson.from.list}},\cr 32 | \code{\link{mongo.bson.to.list}},\cr \link{mongo.bson.iterator},\cr 33 | \link{mongo.bson.buffer},\cr \code{\link{mongo.bson.from.buffer}},\cr 34 | \code{\link{mongo.bson.empty}},\cr \code{\link{mongo.find.one}},\cr 35 | \code{\link{mongo.bson.destroy}}, \code{link{mongo.shorthand}}. 36 | } 37 | 38 | -------------------------------------------------------------------------------- /man/mongo.bson.find.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.find} 3 | \alias{mongo.bson.find} 4 | \title{Find a field within a mongo.bson object by name} 5 | \usage{ 6 | mongo.bson.find(b, name) 7 | } 8 | \arguments{ 9 | \item{b}{(\link{mongo.bson}) The object in which to find the field.} 10 | 11 | \item{name}{(string) The name of the field to find.} 12 | } 13 | \value{ 14 | (\link{mongo.bson.iterator}) An iterator pointing to the field found 15 | if name was found among the names of the fields; otherwise, NULL. 16 | } 17 | \description{ 18 | Find a field within a \link{mongo.bson} object by the name (key) of the 19 | field\cr and return a \link{mongo.bson.iterator} pointing to that field. 20 | } 21 | \details{ 22 | The search parameter may also be a 'dotted' reference to a field in a 23 | subobject or array. See examples. 24 | } 25 | \examples{ 26 | b <- mongo.bson.from.list(list(name="John", age=32L, 27 | address=list(street="Vine", city="Denver", state="CO"))) 28 | iter <- mongo.bson.find(b, "age") 29 | print(mongo.bson.iterator.value(iter)) # print 32 30 | 31 | iter <- mongo.bson.find(b, "address.city") 32 | print(mongo.bson.iterator.value(iter)) # print Denver 33 | 34 | x <- c(1,1,2,3,5) 35 | b <- mongo.bson.from.list(list(fib=x)) 36 | iter <- mongo.bson.find(b, "fib.3") # BSON arrays are 0-based 37 | print(mongo.bson.iterator.value(iter)) # print 3 38 | } 39 | \seealso{ 40 | \link{mongo.bson.iterator},\cr 41 | \code{\link{mongo.bson.iterator.value}},\cr \link{mongo.bson}. 42 | } 43 | 44 | -------------------------------------------------------------------------------- /tests/test_indices.R: -------------------------------------------------------------------------------- 1 | library(rmongodb) 2 | library(RUnit) 3 | 4 | # 3 tests 5 | # 22.11.2013 6 | 7 | # set up mongoDB connection and db / collection parameters 8 | mongo <- mongo.create() 9 | db <- "rmongodb" 10 | ns <- paste(db, "test_indices", sep=".") 11 | 12 | if( mongo.is.connected(mongo) ){ 13 | 14 | # clean up old existing collection 15 | mongo.drop(mongo, ns) 16 | 17 | # for( i in rep(1:10,3)){ 18 | # mongo.insert(mongo, ns, mongo.bson.from.JSON(paste('{"b":',i,'}'))) 19 | # } 20 | # count1 <- mongo.count(mongo, ns) 21 | # out <- mongo.index.create(mongo, ns, "b", options=mongo.index.unique) 22 | # checkTrue( is.null(out) ) 23 | # count2 <- mongo.count(mongo, ns) 24 | # checkTrue( count2 < count1) 25 | 26 | print("test add dup key") 27 | for( i in 1:10){ 28 | mongo.insert(mongo, ns, mongo.bson.from.JSON(paste('{"a":',i,', "b":"', letters[i],'"}', sep=""))) 29 | } 30 | out <- mongo.index.create(mongo, ns, "a", mongo.index.unique) 31 | checkTrue( is.null(out) ) 32 | insert <- mongo.insert(mongo, ns, mongo.bson.from.JSON('{"a":5}')) 33 | checkTrue( !insert ) 34 | 35 | # create indey by key 36 | buf <- mongo.bson.buffer.create() 37 | mongo.bson.buffer.append(buf, "b", "") 38 | mongo.bson.buffer.append(buf, "a", 1L) 39 | b <- mongo.bson.from.buffer(buf) 40 | print("index create") 41 | out <- mongo.index.create(mongo, ns, b) 42 | checkTrue( is.null(out) ) 43 | 44 | # cleanup db and close connection 45 | mongo.drop.database(mongo, db) 46 | mongo.destroy(mongo) 47 | } -------------------------------------------------------------------------------- /man/mongo.bson.buffer.append.code.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.buffer.append.code} 3 | \alias{mongo.bson.buffer.append.code} 4 | \title{Append a code field onto a mongo.bson.buffer} 5 | \usage{ 6 | mongo.bson.buffer.append.code(buf, name, value) 7 | } 8 | \arguments{ 9 | \item{buf}{(\link{mongo.bson.buffer}) The buffer object to which to append.} 10 | 11 | \item{name}{(string) The name (key) of the field appended to the buffer.} 12 | 13 | \item{value}{string} 14 | } 15 | \value{ 16 | TRUE if successful; otherwise, FALSE if an error occured appending 17 | the data. 18 | } 19 | \description{ 20 | Append a javascript code value onto a \link{mongo.bson.buffer}. 21 | } 22 | \details{ 23 | BSON has a special field type to indicate javascript code. This function 24 | appends such an indicator as the type of a field with its value. 25 | } 26 | \examples{ 27 | buf <- mongo.bson.buffer.create() 28 | mongo.bson.buffer.append.code(buf, "SetXtoY", "x = y") 29 | b <- mongo.bson.from.buffer(buf) 30 | 31 | # The above produces a BSON object of the form: 32 | # { "SetXtoY" : (CODE) "x = y" } 33 | 34 | # The same result can be produced by the following code: 35 | buf <- mongo.bson.buffer.create() 36 | code <- mongo.code.create("x = y") 37 | mongo.bson.buffer.append(buf, "SetXtoY", code) 38 | b <- mongo.bson.from.buffer(buf) 39 | } 40 | \seealso{ 41 | \link{mongo.code},\cr \code{\link{mongo.code.create}},\cr 42 | \code{\link{mongo.bson.buffer.append}},\cr \link{mongo.bson},\cr 43 | \link{mongo.bson.buffer}. 44 | } 45 | 46 | -------------------------------------------------------------------------------- /R/utils.R: -------------------------------------------------------------------------------- 1 | mongo.parse.ns <- function(ns) 2 | { 3 | pos <- regexpr('\\.', ns) 4 | if (pos == 0 || pos == -1) { 5 | warning("mongo.parse.ns: No '.' in namespace") 6 | return(NULL) 7 | } else { 8 | db <- substr(ns, 1, pos-1) 9 | collection <- substr(ns, pos+1, nchar(ns)) 10 | return(list(db=db, collection=collection)) 11 | } 12 | } 13 | 14 | mongo.bson.from.argument <- function(arg) { 15 | bson <- switch( class(arg), 16 | "mongo.bson" = arg, 17 | "list" = mongo.bson.from.list(arg), 18 | "character" = mongo.bson.from.JSON(arg), 19 | stop("Can't convert to bson: argument should be one of 'list', 'mongo.bson' or 'character'(valid JSON)") 20 | ) 21 | return(bson) 22 | } 23 | 24 | mongo.list.from.argument <- function(arg, simplify = T) { 25 | lst <- switch( class(arg), 26 | "list" = arg, 27 | "mongo.bson" = mongo.bson.to.list(arg, simplify = simplify), 28 | "character" = { 29 | if( !jsonlite::validate(I(arg)) ) stop("Not a valid JSON content: ", arg) 30 | else jsonlite::fromJSON(arg)}, 31 | stop("Can't convert to list: argument should be one of 'list', 'mongo.bson' or 'character'(valid JSON)") 32 | ) 33 | return(lst) 34 | } 35 | 36 | # make flat list without type coercion 37 | flatten <- function(lst) { 38 | lst[['__dummy']] <- function() NULL 39 | lst <- unlist(lst) 40 | lst[['__dummy']] <- NULL 41 | lst 42 | } 43 | -------------------------------------------------------------------------------- /man/mongo.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{class} 3 | \name{mongo} 4 | \alias{mongo} 5 | \title{The mongo (database connection) class} 6 | \description{ 7 | Objects of class "mongo" are used to connect to a MongoDB server and to 8 | perform database operations on that server. 9 | } 10 | \details{ 11 | mongo objects have "mongo" as their class and contain an externally managed 12 | pointer to the connection data. This pointer is stored in the "mongo" 13 | attribute of the object. 14 | 15 | Note that the members of the mongo object only reflect\cr the initial 16 | parameters of \code{\link{mongo.create}()}. Only the external data actually 17 | changes if, for example, mongo.timeout is called after the initial call to 18 | \code{mongo.create}. 19 | } 20 | \examples{ 21 | mongo <- mongo.create() 22 | if (mongo.is.connected(mongo)) { 23 | buf <- mongo.bson.buffer.create() 24 | mongo.bson.buffer.append(buf, "name", "Joe") 25 | mongo.bson.buffer.append(buf, "age", 22L) 26 | b <- mongo.bson.from.buffer(buf) 27 | mongo.insert(mongo, "test.people", b) 28 | } 29 | } 30 | \seealso{ 31 | \code{\link{mongo.create}},\cr \code{\link{mongo.is.connected}},\cr 32 | \code{\link{mongo.get.databases}},\cr 33 | \code{\link{mongo.get.database.collections}},\cr 34 | \code{\link{mongo.insert}},\cr \code{\link{mongo.find.one}},\cr 35 | \code{\link{mongo.find}},\cr \code{\link{mongo.update}},\cr 36 | \code{\link{mongo.remove}},\cr \code{\link{mongo.drop}},\cr 37 | \code{\link{mongo.drop.database}}\cr \link{mongo.gridfs}. 38 | } 39 | 40 | -------------------------------------------------------------------------------- /man/mongo.code.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{class} 3 | \name{mongo.code} 4 | \alias{mongo.code} 5 | \title{The mongo.code class} 6 | \description{ 7 | Objects of class "mongo.code" are used to represent javascript code values 8 | in BSON documents. 9 | } 10 | \details{ 11 | mongo.code objects' value is a string representing the value of the code. 12 | 13 | mongo.code objects have "mongo.code" as their class so that\cr 14 | \code{\link{mongo.bson.buffer.append}()} may detect them and append the 15 | appropriate BSON code-typed value to a buffer. 16 | 17 | These mongo.code values may also be present in a list and\cr will be handled 18 | properly by \code{\link{mongo.bson.buffer.append.list}()} and\cr 19 | \code{\link{mongo.bson.from.list}()}. 20 | } 21 | \examples{ 22 | buf <- mongo.bson.buffer.create() 23 | code <- mongo.code.create("y = x") 24 | mongo.bson.buffer.append(buf, "Code", code) 25 | lst <- list(c1 = code, One = 1) 26 | mongo.bson.buffer.append.list(buf, "listWcode", lst) 27 | mongo.bson.buffer.append.code(buf, "Code2", "a = 1") 28 | b <- mongo.bson.from.buffer(buf) 29 | 30 | # the above will create a mongo.bson object of the following form: 31 | # { "Code": (CODE) "y = x", 32 | # "listWcode" : { "c1" : (CODE) "y = x", 33 | # "One" : 1 }, 34 | # "Code2" : (CODE) "a = 1" } 35 | } 36 | \seealso{ 37 | \code{\link{mongo.code.create}},\cr 38 | \code{\link{mongo.bson.buffer.append}},\cr 39 | \code{\link{mongo.bson.buffer.append.list}},\cr \link{mongo.bson.buffer},\cr 40 | \link{mongo.bson}. 41 | } 42 | 43 | -------------------------------------------------------------------------------- /man/mongo.bson.buffer.append.bson.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.buffer.append.bson} 3 | \alias{mongo.bson.buffer.append.bson} 4 | \title{Append a mongo.bson object into a mongo.bson.buffer} 5 | \usage{ 6 | mongo.bson.buffer.append.bson(buf, name, value) 7 | } 8 | \arguments{ 9 | \item{buf}{(\link{mongo.bson.buffer}) The buffer object to which to append.} 10 | 11 | \item{name}{(string) The name (key) of the subobject field appended to the 12 | buffer.} 13 | 14 | \item{value}{(\link{mongo.bson}) a mongo.bson object.} 15 | } 16 | \value{ 17 | TRUE if successful; otherwise, FALSE if an error occured appending 18 | the data. 19 | } 20 | \description{ 21 | Append a \link{mongo.bson} object into a \link{mongo.bson.buffer} as a 22 | subobject. 23 | } 24 | \details{ 25 | Note that \code{\link{mongo.bson.buffer.append}()} will detect if its value 26 | parameter is a mongo.bson object and perform the same action as this 27 | function. 28 | } 29 | \examples{ 30 | name <- mongo.bson.from.list(list(first="Joe", last="Smith")) 31 | buf <- mongo.bson.buffer.create() 32 | mongo.bson.buffer.append.bson(buf, "name", name) 33 | mongo.bson.buffer.append.string(buf, "city", "New York") 34 | b <- mongo.bson.from.buffer(buf) 35 | 36 | # the above will create a mongo.bson object of the following form: 37 | # { "name" : { "first" : "Joe", "last" : "Smith" }, "city" : "New York" } 38 | } 39 | \seealso{ 40 | \link{mongo.bson},\cr \link{mongo.bson.buffer},\cr 41 | \code{\link{mongo.bson.from.list}},\cr 42 | \code{\link{mongo.bson.buffer.append}}. 43 | } 44 | 45 | -------------------------------------------------------------------------------- /man/mongo.get.err.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.get.err} 3 | \alias{mongo.get.err} 4 | \title{Retrieve an connection error code from a mongo object} 5 | \usage{ 6 | mongo.get.err(mongo) 7 | } 8 | \arguments{ 9 | \item{mongo}{(\link{mongo}) a mongo connection object.} 10 | } 11 | \value{ 12 | (integer) error code as follows: 13 | \itemize{ 14 | \item 0 No Error 15 | \item 1 No socket - Could not create socket. 16 | \item 2 Fail - An error occurred attempting to connect to socket 17 | \item 3 Address fail - An error occured calling getaddrinfo(). 18 | \item 4 Not Master - Warning: connected to a non-master node 19 | (read-only). 20 | \item 5 Bad set name - given name doesn't match the replica set. 21 | \item 6 No Primary - Cannot find primary in replica set - connection 22 | closed. 23 | \item 7 I/O error - An error occured reading or writing on the socket. 24 | \item 8 Read size error - The response is not the expected length. 25 | \item 9 Command failed - The command returned with 'ok' value of 0. 26 | \item 10 BSON invalid - Not valid for the specified operation. 27 | \item 11 BSON not finished - should not occur with R driver. 28 | } 29 | } 30 | \description{ 31 | Retrieve an connection error code from a mongo object indicating the failure 32 | code if mongo.create() failed. 33 | } 34 | \examples{ 35 | mongo <- mongo.create() 36 | if (!mongo.is.connected(mongo)) { 37 | print("Unable to connect. Error code:") 38 | print(mongo.get.err(mongo)) 39 | } 40 | } 41 | \seealso{ 42 | \code{\link{mongo.create}},\cr \link{mongo} 43 | } 44 | 45 | -------------------------------------------------------------------------------- /man/mongo.gridfs.create.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.gridfs.create} 3 | \alias{mongo.gridfs.create} 4 | \title{Create a mongo.gridfs object} 5 | \usage{ 6 | mongo.gridfs.create(mongo, db, prefix = "fs") 7 | } 8 | \arguments{ 9 | \item{mongo}{A (\link{mongo}) connection object.} 10 | 11 | \item{db}{(string) The name of the database in which to access and/or store 12 | the gridfs-related collections.} 13 | 14 | \item{prefix}{(string) The prefix to use constructing the gridfs-related 15 | collection names. There are two collections used for this purpose:\cr 16 | \"\code{db}.\code{prefix}.files\" and \"\code{db}.\code{prefix}.chunks\".} 17 | } 18 | \value{ 19 | (\link{mongo.gridfs}) An object to be used for subsequent operations 20 | on the grid file store. 21 | } 22 | \description{ 23 | Create a \link{mongo.gridfs} object used to access and store "grid files" on 24 | the MongoDB server. 25 | } 26 | \examples{ 27 | mongo <- mongo.create() 28 | if (mongo.is.connected(mongo)) { 29 | gridfs <- mongo.gridfs.create(mongo, "grid") 30 | # Copy a local file to the server as a gridfs file 31 | mongo.gridfs.store.file(gridfs, "tests/test.R", "test.R") 32 | mongo.gridfs.destroy(gridfs) 33 | } 34 | } 35 | \seealso{ 36 | \link{mongo.gridfs},\cr \code{\link{mongo.gridfs.destroy}},\cr 37 | \code{\link{mongo.gridfs.store.file}},\cr 38 | \code{\link{mongo.gridfs.remove.file}},\cr 39 | \code{\link{mongo.gridfs.store}},\cr 40 | \code{\link{mongo.gridfile.writer.create}},\cr 41 | \code{\link{mongo.gridfs.find}}, \code{link{mongo.shorthand}}. 42 | } 43 | 44 | -------------------------------------------------------------------------------- /man/mongo.insert.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.insert} 3 | \alias{mongo.insert} 4 | \title{Add record to a collection} 5 | \usage{ 6 | mongo.insert(mongo, ns, b) 7 | } 8 | \arguments{ 9 | \item{mongo}{(\link{mongo}) a mongo connection object.} 10 | 11 | \item{ns}{(string) namespace of the collection to which to add the record.} 12 | 13 | \item{b}{(\link{mongo.bson}) The record to add. 14 | 15 | In addition, \code{b} may be a list which will be converted to a mongo.bson 16 | object by \code{\link{mongo.bson.from.list}()}.} 17 | } 18 | \value{ 19 | TRUE if the command was successfully sent to the server; otherwise, 20 | FALSE. 21 | 22 | \code{\link{mongo.get.last.err}()} may be examined to verify that the insert 23 | was successful on the server if necessary. 24 | } 25 | \description{ 26 | Add record to a collection. 27 | } 28 | \details{ 29 | See \url{http://www.mongodb.org/display/DOCS/Inserting}. 30 | } 31 | \examples{ 32 | mongo <- mongo.create() 33 | if (mongo.is.connected(mongo)) { 34 | ns <- "test.people" 35 | 36 | buf <- mongo.bson.buffer.create() 37 | mongo.bson.buffer.append(buf, "name", "Joe") 38 | mongo.bson.buffer.append(buf, "age", 22L) 39 | b <- mongo.bson.from.buffer(buf) 40 | mongo.insert(mongo, ns, b) 41 | 42 | # do the same thing in shorthand: 43 | mongo.insert(mongo, ns, list(name="Joe", age=22L)) 44 | } 45 | } 46 | \seealso{ 47 | \code{\link{mongo.insert.batch}},\cr \code{\link{mongo.update}},\cr 48 | \code{\link{mongo.find}},\cr \code{\link{mongo.find.one}},\cr 49 | \code{\link{mongo.remove}},\cr \link{mongo.bson},\cr \link{mongo}. 50 | } 51 | 52 | -------------------------------------------------------------------------------- /man/mongo.cursor.to.data.frame.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.cursor.to.data.frame} 3 | \alias{mongo.cursor.to.data.frame} 4 | \title{Convert Mongo Cursor Object to Data.Frame} 5 | \usage{ 6 | mongo.cursor.to.data.frame(cursor, nullToNA = TRUE, ...) 7 | } 8 | \arguments{ 9 | \item{cursor}{(\link{mongo.cursor}) A mongo.cursor object returned from 10 | \code{\link{mongo.find}()}.} 11 | 12 | \item{nullToNA}{(boolean) If \code{NULL} values will be torned into \code{NA} values. 13 | Usually this is a good idea, because sporadic \code{NULL} values will cause structural 14 | problems in the data.frame, whereas \code{NA} values will just appear as regular \code{NA}s.} 15 | 16 | \item{...}{Additional parameters parsed to the function \code{\link{as.data.frame}}} 17 | } 18 | \value{ 19 | An R data.frame object. 20 | } 21 | \description{ 22 | Converts a mongo cursor object to a data.frame by interating over all cursor objects and combining them. 23 | } 24 | \details{ 25 | Note that mongo.oid columns will be removed. data.frame can not deal with them. 26 | } 27 | \examples{ 28 | mongo <- mongo.create() 29 | if (mongo.is.connected(mongo)) { 30 | buf <- mongo.bson.buffer.create() 31 | mongo.bson.buffer.append(buf, "age", 22L) 32 | query <- mongo.bson.from.buffer(buf) 33 | 34 | # Find the first 100 records 35 | # in collection people of database test where age == 22 36 | cursor <- mongo.find(mongo, "test.people", query, limit=100L) 37 | 38 | res <- mongo.cursor.to.data.frame(cursor) 39 | 40 | } 41 | } 42 | \seealso{ 43 | \code{\link{mongo.find}},\cr \code{\link{as.data.frame}}. 44 | } 45 | 46 | -------------------------------------------------------------------------------- /man/mongo.simple.command.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.simple.command} 3 | \alias{mongo.simple.command} 4 | \title{Issue a simple.command to a database on MongoDB server} 5 | \usage{ 6 | mongo.simple.command(mongo, db, cmdstr, arg) 7 | } 8 | \arguments{ 9 | \item{mongo}{(\link{mongo}) A mongo connection object.} 10 | 11 | \item{db}{(string) The name of the database upon which to perform the 12 | command.} 13 | 14 | \item{cmdstr}{(string) The name of the command.} 15 | 16 | \item{arg}{An argument to the command, may be a string or numeric 17 | (as.integer).} 18 | } 19 | \value{ 20 | NULL if the command failed. Use \code{\link{mongo.get.last.err}()} 21 | to determine the cause. 22 | 23 | (\link{mongo.bson}) The server's response if successful. 24 | } 25 | \description{ 26 | Issue a simple command to a MongoDB server and return the response from the 27 | server. 28 | } 29 | \details{ 30 | This function supports many of the MongoDB database commands by allowing you 31 | to specify a simple command object which is entirely specified by the 32 | command name and an integer or string argument. 33 | 34 | See \url{http://www.mongodb.org/display/DOCS/List+of+Database+Commands}. 35 | } 36 | \examples{ 37 | mongo <- mongo.create() 38 | if (mongo.is.connected(mongo)) { 39 | print(mongo.simple.command(mongo, "admin", "buildInfo", 1)) 40 | 41 | mongo.destroy(mongo) 42 | } 43 | } 44 | \seealso{ 45 | \code{\link{mongo.command}},\cr \code{\link{mongo.rename}},\cr 46 | \code{\link{mongo.count}},\cr \code{\link{mongo.drop.database}},\cr 47 | \code{\link{mongo.drop}},\cr \link{mongo},\cr \link{mongo.bson}. 48 | } 49 | 50 | -------------------------------------------------------------------------------- /man/mongo.bson.buffer.finish.object.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.buffer.finish.object} 3 | \alias{mongo.bson.buffer.finish.object} 4 | \title{Finish a subobject or array within a mongo.bson.buffer} 5 | \usage{ 6 | mongo.bson.buffer.finish.object(buf) 7 | } 8 | \arguments{ 9 | \item{buf}{(\link{mongo.bson.buffer}) The buffer object on which to finish a 10 | subobject.} 11 | } 12 | \value{ 13 | TRUE if successful; otherwise, FALSE if an error occured appending 14 | the data. 15 | } 16 | \description{ 17 | BSON documents may themselves contain nested documents. Call this function 18 | to finish a subobject within a \link{mongo.bson.buffer}. 19 | } 20 | \details{ 21 | \code{\link{mongo.bson.buffer.start.object}()} and 22 | \code{mongo.bson.buffer.finish.object()} may be called in a stackwise (LIFO) 23 | order to further nest documents. 24 | 25 | This function must also be called to finish arrays. 26 | } 27 | \examples{ 28 | buf <- mongo.bson.buffer.create() 29 | mongo.bson.buffer.start.object(buf, "name") 30 | mongo.bson.buffer.append(buf, "first", "Jeff") 31 | mongo.bson.buffer.append(buf, "last", "Davis") 32 | mongo.bson.buffer.finish.object(buf) 33 | mongo.bson.buffer.append(buf, "city", "Toronto") 34 | b <- mongo.bson.from.buffer(buf) 35 | 36 | # the above produces a BSON object of the form: 37 | # { "name" : { "first" : "Jeff", "last" : "Davis" }, "city" : "Toronto" } 38 | } 39 | \seealso{ 40 | \link{mongo.bson},\cr \link{mongo.bson.buffer},\cr 41 | \code{\link{mongo.bson.buffer.start.object}},\cr 42 | \code{\link{mongo.bson.buffer.start.array}},\cr 43 | \code{\link{mongo.bson.buffer.append}}. 44 | } 45 | 46 | -------------------------------------------------------------------------------- /man/mongo.gridfile.get.length.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.gridfile.get.length} 3 | \alias{mongo.gridfile.get.length} 4 | \title{Get the length of a mongo.gridfile} 5 | \usage{ 6 | mongo.gridfile.get.length(gridfile) 7 | } 8 | \arguments{ 9 | \item{gridfile}{A (\link{mongo.gridfile}) object.} 10 | } 11 | \value{ 12 | (double) The length of \code{gridfile}. 13 | } 14 | \description{ 15 | Get the length of a \link{mongo.gridfile}. 16 | } 17 | \examples{ 18 | mongo <- mongo.create() 19 | if (mongo.is.connected(mongo)) { 20 | gridfs <- mongo.gridfs.create(mongo, "grid") 21 | mongo.gridfs.store.file(gridfs, "tests/test.R", "test.R") 22 | 23 | gf <- mongo.gridfs.find(gridfs, "test.R") 24 | if( !is.null(gf) ){ 25 | print(mongo.gridfile.get.length(gf)) 26 | 27 | mongo.gridfile.destroy(gf) 28 | } 29 | mongo.gridfs.destroy(gridfs) 30 | } 31 | } 32 | \seealso{ 33 | \code{\link{mongo.gridfs}},\cr \code{\link{mongo.gridfs.find}},\cr 34 | \link{mongo.gridfile},\cr \code{\link{mongo.gridfile.get.descriptor}},\cr 35 | \code{\link{mongo.gridfile.get.filename}},\cr 36 | \code{\link{mongo.gridfile.get.chunk.size}},\cr 37 | \code{\link{mongo.gridfile.get.chunk.count}},\cr 38 | \code{\link{mongo.gridfile.get.content.type}},\cr 39 | \code{\link{mongo.gridfile.get.upload.date}},\cr 40 | \code{\link{mongo.gridfile.get.md5}},\cr 41 | \code{\link{mongo.gridfile.get.metadata}},\cr 42 | \code{\link{mongo.gridfile.get.chunk}},\cr 43 | \code{\link{mongo.gridfile.get.chunks}},\cr 44 | \code{\link{mongo.gridfile.read}},\cr \code{\link{mongo.gridfile.seek}},\cr 45 | \code{\link{mongo.gridfile.pipe}}. 46 | } 47 | 48 | -------------------------------------------------------------------------------- /man/mongo.bson.buffer.append.element.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.buffer.append.element} 3 | \alias{mongo.bson.buffer.append.element} 4 | \title{Append a mongo.bson.iterator's element into a mongo.bson.buffer} 5 | \usage{ 6 | mongo.bson.buffer.append.element(buf, name, value) 7 | } 8 | \arguments{ 9 | \item{buf}{(\link{mongo.bson.buffer}) The buffer object to which to append.} 10 | 11 | \item{name}{(string) The name (key) of the subobject field appended to the 12 | buffer. 13 | 14 | If NULL, the name appended will come from the element pointed to by the 15 | iterator.} 16 | 17 | \item{value}{A (\link{mongo.bson.iterator}) object.} 18 | } 19 | \value{ 20 | TRUE if successful; otherwise, FALSE if an error occured appending 21 | the data. 22 | } 23 | \description{ 24 | Append a \link{mongo.bson.iterator}'s element into a 25 | \link{mongo.bson.buffer}. 26 | } 27 | \details{ 28 | \code{\link{mongo.bson.buffer.append}()} will detect if its value parameter 29 | is a mongo.bson.iterator object and perform the same action as this 30 | function. 31 | } 32 | \examples{ 33 | name <- mongo.bson.from.list(list(first="Joe", last="Smith")) 34 | iter <- mongo.bson.find(name, "last") 35 | buf <- mongo.bson.buffer.create() 36 | mongo.bson.buffer.append.element(buf, "last", iter) 37 | b <- mongo.bson.from.buffer(buf) 38 | 39 | # the above will create a mongo.bson object (b) of the following form: 40 | # { "last" : "Smith" } 41 | } 42 | \seealso{ 43 | \link{mongo.bson},\cr \link{mongo.bson.buffer},\cr 44 | \code{\link{mongo.bson.find}},\cr \code{\link{mongo.bson.from.list}},\cr 45 | \code{\link{mongo.bson.buffer.append}}. 46 | } 47 | 48 | -------------------------------------------------------------------------------- /man/mongo.cursor.to.list.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.cursor.to.list} 3 | \alias{mongo.cursor.to.list} 4 | \alias{mongo.cursor.to.rlist} 5 | \title{Convert Mongo Cursor Object to List so that each element of resulting list represents document in source collection.} 6 | \usage{ 7 | mongo.cursor.to.list(cursor, keep.ordering = TRUE) 8 | } 9 | \arguments{ 10 | \item{cursor}{(\link{mongo.cursor}) A mongo.cursor object returned from \code{\link{mongo.find}()}.} 11 | 12 | \item{keep.ordering}{should the records be returned at the same order as fetched from cursor (if sorting was specified in query)? 13 | For speed try to set this parameter to FALSE. This will prevent sorting after fetching from cursor.} 14 | } 15 | \value{ 16 | An R \link{list} object. 17 | } 18 | \description{ 19 | Converts a mongo cursor object to a list by interating over all cursor objects and combining them. 20 | It doesn't make any data coercion!, just one-to-one mapping with documents in source collection. 21 | } 22 | \details{ 23 | Since rmongodb 1.8.0 function uses environments to avoid extra copying, so now it is much faster. 24 | } 25 | \examples{ 26 | mongo <- mongo.create() 27 | if (mongo.is.connected(mongo)) { 28 | buf <- mongo.bson.buffer.create() 29 | mongo.bson.buffer.append(buf, "age", 22L) 30 | query <- mongo.bson.from.buffer(buf) 31 | 32 | # Find the first 100 records 33 | # in collection people of database test where age == 22 34 | cursor <- mongo.find(mongo, "test.people", query, limit=100L) 35 | 36 | res <- mongo.cursor.to.list(cursor) 37 | 38 | } 39 | } 40 | \seealso{ 41 | \code{\link{mongo.find}} 42 | } 43 | 44 | -------------------------------------------------------------------------------- /man/mongo.gridfile.get.md5.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.gridfile.get.md5} 3 | \alias{mongo.gridfile.get.md5} 4 | \title{Get the MD5 hash of a mongo.gridfile} 5 | \usage{ 6 | mongo.gridfile.get.md5(gridfile) 7 | } 8 | \arguments{ 9 | \item{gridfile}{A (\link{mongo.gridfile}) object.} 10 | } 11 | \value{ 12 | (string) The MD5 hash (32 hex digits) of \code{gridfile}. 13 | } 14 | \description{ 15 | Get the MD5 hash of a \link{mongo.gridfile}. 16 | } 17 | \examples{ 18 | mongo <- mongo.create() 19 | if (mongo.is.connected(mongo)) { 20 | gridfs <- mongo.gridfs.create(mongo, "grid") 21 | mongo.gridfs.store.file(gridfs, "tests/test.R", "test.R") 22 | 23 | gf <- mongo.gridfs.find(gridfs, "test.R") 24 | if( !is.null(gf) ){ 25 | print(mongo.gridfile.get.md5(gf)) 26 | 27 | mongo.gridfile.destroy(gf) 28 | } 29 | mongo.gridfs.destroy(gridfs) 30 | } 31 | } 32 | \seealso{ 33 | \code{\link{mongo.gridfs}},\cr \code{\link{mongo.gridfs.find}},\cr 34 | \link{mongo.gridfile},\cr \code{\link{mongo.gridfile.get.descriptor}},\cr 35 | \code{\link{mongo.gridfile.get.filename}},\cr 36 | \code{\link{mongo.gridfile.get.length}},\cr 37 | \code{\link{mongo.gridfile.get.chunk.size}},\cr 38 | \code{\link{mongo.gridfile.get.chunk.count}},\cr 39 | \code{\link{mongo.gridfile.get.content.type}},\cr 40 | \code{\link{mongo.gridfile.get.upload.date}},\cr 41 | \code{\link{mongo.gridfile.get.metadata}},\cr 42 | \code{\link{mongo.gridfile.get.chunk}},\cr 43 | \code{\link{mongo.gridfile.get.chunks}},\cr 44 | \code{\link{mongo.gridfile.read}},\cr \code{\link{mongo.gridfile.seek}},\cr 45 | \code{\link{mongo.gridfile.pipe}}. 46 | } 47 | 48 | -------------------------------------------------------------------------------- /man/mongo.cursor.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{class} 3 | \name{mongo.cursor} 4 | \alias{mongo.cursor} 5 | \title{The mongo.cursor class} 6 | \description{ 7 | Objects of class "mongo.cursor" are returned from \code{\link{mongo.find}()} 8 | and used to iterate over the records matching the query. 9 | } 10 | \details{ 11 | \code{\link{mongo.cursor.next}(cursor)} is used to step to the first or next 12 | record. 13 | 14 | \code{\link{mongo.cursor.value}(cursor)} returns a mongo.bson object 15 | representing the current record. 16 | 17 | \code{\link{mongo.cursor.destroy}(cursor)} releases the resources attached 18 | to the cursor. 19 | 20 | mongo.cursor objects have "mongo.cursor" as their class and contain an 21 | externally managed pointer to the actual cursor data. This pointer is stored 22 | in the "mongo.cursor" attribute of the object. 23 | } 24 | \examples{ 25 | mongo <- mongo.create() 26 | if (mongo.is.connected(mongo)) { 27 | buf <- mongo.bson.buffer.create() 28 | mongo.bson.buffer.append(buf, "city", "St. Louis") 29 | query <- mongo.bson.from.buffer(buf) 30 | 31 | # Find the first 1000 records in collection people 32 | # of database test where city == "St. Louis" 33 | cursor <- mongo.find(mongo, "test.people", query, limit=1000L) 34 | # Step though the matching records and display them 35 | while (mongo.cursor.next(cursor)) 36 | print(mongo.cursor.value(cursor)) 37 | mongo.cursor.destroy(cursor) 38 | } 39 | } 40 | \seealso{ 41 | \code{\link{mongo.find}},\cr \code{\link{mongo.cursor.next}},\cr 42 | \code{\link{mongo.cursor.value}},\cr \code{\link{mongo.cursor.destroy}}. 43 | } 44 | 45 | -------------------------------------------------------------------------------- /man/mongo.bson.buffer.append.symbol.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.buffer.append.symbol} 3 | \alias{mongo.bson.buffer.append.symbol} 4 | \title{Append a symbol field onto a mongo.bson.buffer} 5 | \usage{ 6 | mongo.bson.buffer.append.symbol(buf, name, value) 7 | } 8 | \arguments{ 9 | \item{buf}{(\link{mongo.bson.buffer}) The buffer object to which to append.} 10 | 11 | \item{name}{(string) The name (key) of the field appended to the buffer.} 12 | 13 | \item{value}{(string) The value of the symbol. 14 | 15 | Note that the value may simply be a string representing the symbol's value 16 | and not necessarily a \link{mongo.symbol} object.} 17 | } 18 | \value{ 19 | TRUE if successful; otherwise, FALSE if an error occured appending 20 | the data. 21 | } 22 | \description{ 23 | Append a symbol value onto a \link{mongo.bson.buffer}. 24 | } 25 | \details{ 26 | BSON has a special field type to indicate a symbol. This function appends 27 | such an indicator as the type of a field with its value. 28 | } 29 | \examples{ 30 | buf <- mongo.bson.buffer.create() 31 | mongo.bson.buffer.append.symbol(buf, "A", "Alpha") 32 | b <- mongo.bson.from.buffer(buf) 33 | 34 | # The above produces a BSON object of the form { "A" : (SYMBOL) "Alpha" } 35 | 36 | # The same result can be produced by the following code: 37 | buf <- mongo.bson.buffer.create() 38 | sym <- mongo.symbol.create("Alpha") 39 | mongo.bson.buffer.append(buf, "A", sym) 40 | b <- mongo.bson.from.buffer(buf) 41 | } 42 | \seealso{ 43 | \link{mongo.bson},\cr \link{mongo.bson.buffer},\cr 44 | \link{mongo.symbol},\cr \code{\link{mongo.symbol.create}},\cr 45 | \code{\link{mongo.bson.buffer.append}}. 46 | } 47 | 48 | -------------------------------------------------------------------------------- /man/mongo.gridfile.get.upload.date.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.gridfile.get.upload.date} 3 | \alias{mongo.gridfile.get.upload.date} 4 | \title{Get the upload date of a mongo.gridfile} 5 | \usage{ 6 | mongo.gridfile.get.upload.date(gridfile) 7 | } 8 | \arguments{ 9 | \item{gridfile}{A (\link{mongo.gridfile}) object.} 10 | } 11 | \value{ 12 | (POSIXct) The upload date/time of \code{gridfile}. 13 | } 14 | \description{ 15 | Get the upload date of a \link{mongo.gridfile}. 16 | } 17 | \examples{ 18 | mongo <- mongo.create() 19 | if (mongo.is.connected(mongo)) { 20 | gridfs <- mongo.gridfs.create(mongo, "grid") 21 | mongo.gridfs.store.file(gridfs, "tests/test.R", "test.R") 22 | 23 | gf <- mongo.gridfs.find(gridfs, "test.R") 24 | if( !is.null(gf) ){ 25 | print(mongo.gridfile.get.upload.date(gf)) 26 | 27 | mongo.gridfile.destroy(gf) 28 | } 29 | mongo.gridfs.destroy(gridfs) 30 | } 31 | } 32 | \seealso{ 33 | \code{\link{mongo.gridfs}},\cr \code{\link{mongo.gridfs.find}},\cr 34 | \link{mongo.gridfile},\cr \code{\link{mongo.gridfile.get.descriptor}},\cr 35 | \code{\link{mongo.gridfile.get.filename}},\cr 36 | \code{\link{mongo.gridfile.get.length}},\cr 37 | \code{\link{mongo.gridfile.get.chunk.size}},\cr 38 | \code{\link{mongo.gridfile.get.chunk.count}},\cr 39 | \code{\link{mongo.gridfile.get.content.type}},\cr 40 | \code{\link{mongo.gridfile.get.md5}},\cr 41 | \code{\link{mongo.gridfile.get.metadata}},\cr 42 | \code{\link{mongo.gridfile.get.chunk}},\cr 43 | \code{\link{mongo.gridfile.get.chunks}},\cr 44 | \code{\link{mongo.gridfile.read}},\cr \code{\link{mongo.gridfile.seek}},\cr 45 | \code{\link{mongo.gridfile.pipe}}. 46 | } 47 | 48 | -------------------------------------------------------------------------------- /man/mongo.gridfile.get.chunk.size.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.gridfile.get.chunk.size} 3 | \alias{mongo.gridfile.get.chunk.size} 4 | \title{Get the chunk.size of a mongo.gridfile} 5 | \usage{ 6 | mongo.gridfile.get.chunk.size(gridfile) 7 | } 8 | \arguments{ 9 | \item{gridfile}{A (\link{mongo.gridfile}) object.} 10 | } 11 | \value{ 12 | (integer) The chunk size of \code{gridfile}. 13 | } 14 | \description{ 15 | Get the chunk size of a \link{mongo.gridfile}. This is the size of the 16 | chunks into which file is broken up on the server. 17 | } 18 | \examples{ 19 | mongo <- mongo.create() 20 | if (mongo.is.connected(mongo)) { 21 | gridfs <- mongo.gridfs.create(mongo, "grid") 22 | 23 | gf <- mongo.gridfs.find(gridfs, "test.R") 24 | if( !is.null(gf)){ 25 | print(mongo.gridfile.get.chunk.size(gf)) 26 | 27 | mongo.gridfile.destroy(gf) 28 | } 29 | mongo.gridfs.destroy(gridfs) 30 | } 31 | } 32 | \seealso{ 33 | \code{\link{mongo.gridfs}},\cr \code{\link{mongo.gridfs.find}},\cr 34 | \link{mongo.gridfile},\cr \code{\link{mongo.gridfile.get.descriptor}},\cr 35 | \code{\link{mongo.gridfile.get.filename}},\cr 36 | \code{\link{mongo.gridfile.get.length}},\cr 37 | \code{\link{mongo.gridfile.get.chunk.count}},\cr 38 | \code{\link{mongo.gridfile.get.content.type}},\cr 39 | \code{\link{mongo.gridfile.get.upload.date}},\cr 40 | \code{\link{mongo.gridfile.get.md5}},\cr 41 | \code{\link{mongo.gridfile.get.metadata}},\cr 42 | \code{\link{mongo.gridfile.get.chunk}},\cr 43 | \code{\link{mongo.gridfile.get.chunks}},\cr 44 | \code{\link{mongo.gridfile.read}},\cr \code{\link{mongo.gridfile.seek}},\cr 45 | \code{\link{mongo.gridfile.pipe}}. 46 | } 47 | 48 | -------------------------------------------------------------------------------- /tests/test_update.R: -------------------------------------------------------------------------------- 1 | library(rmongodb) 2 | library(RUnit) 3 | 4 | # 1 tests 5 | # 22.11.2013 6 | 7 | # set up mongoDB connection and db / collection parameters 8 | mongo <- mongo.create() 9 | db <- "rmongodb" 10 | ns <- paste(db, "test_update", sep=".") 11 | 12 | if( mongo.is.connected(mongo) ){ 13 | 14 | # clean up old existing collection 15 | mongo.drop(mongo, ns) 16 | 17 | # inster data 18 | buf <- mongo.bson.buffer.create() 19 | mongo.bson.buffer.append(buf, "name", "Dave") 20 | mongo.bson.buffer.append(buf, "age", 27L) 21 | x <- mongo.bson.from.buffer(buf) 22 | buf <- mongo.bson.buffer.create() 23 | mongo.bson.buffer.append(buf, "name", "Fred") 24 | mongo.bson.buffer.append(buf, "age", 31L) 25 | y <- mongo.bson.from.buffer(buf) 26 | buf <- mongo.bson.buffer.create() 27 | mongo.bson.buffer.append(buf, "name", "Silvia") 28 | mongo.bson.buffer.append(buf, "age", 24L) 29 | z <- mongo.bson.from.buffer(buf) 30 | mongo.insert.batch(mongo, ns, list(x, y, z)) 31 | 32 | 33 | # update one document 34 | buf <- mongo.bson.buffer.create() 35 | mongo.bson.buffer.append(buf, "name", "Silvia") 36 | query <- mongo.bson.from.buffer(buf) 37 | 38 | buf <- mongo.bson.buffer.create() 39 | mongo.bson.buffer.start.object(buf, "$inc") 40 | mongo.bson.buffer.append(buf, "age", 1L) 41 | mongo.bson.buffer.finish.object(buf) 42 | op <- mongo.bson.from.buffer(buf) 43 | 44 | mongo.update(mongo, ns, query, op) 45 | 46 | checkEquals( 47 | mongo.bson.value( mongo.find.one(mongo, ns, query), "age"), 48 | mongo.bson.value( z, "age") +1 ) 49 | 50 | # cleanup db and close connection 51 | mongo.drop.database(mongo, db) 52 | mongo.destroy(mongo) 53 | } -------------------------------------------------------------------------------- /man/mongo.bson.to.list.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.to.list} 3 | \alias{mongo.bson.to.list} 4 | \title{Convert a mongo.bson object to an R list object.} 5 | \usage{ 6 | mongo.bson.to.list(b, simplify = TRUE) 7 | } 8 | \arguments{ 9 | \item{b}{(\link{mongo.bson}) The mongo.bson object to convert.} 10 | 11 | \item{simplify}{\link{logical} (default: TRUE); should the bson arrays be simplified to a vectors if possible? 12 | If types of values in bson array are heterogeneous or non-primitive, array will be converted into list.} 13 | } 14 | \value{ 15 | an R object of the type list 16 | } 17 | \description{ 18 | Convert a \link{mongo.bson} object to an R list object. 19 | } 20 | \note{ 21 | Now arrays in bson document are 1) converted into unnamed lists 2) If simplify == TRUE, function tries 22 | to turn arrays of primitive types into R vectors. 23 | Please see examples below; 24 | } 25 | \examples{ 26 | # arrays will be converted into unnamed lists without any symplifying: 27 | l <- list(storageArray = list('value_1', 'value_2')) 28 | # Here we construct bson of form {'storageArray':['value_1''value_2']} 29 | b <- mongo.bson.from.list(l) 30 | # simplify 31 | print(mongo.bson.to.list(b, simplify = TRUE)) 32 | # not simplify 33 | print(mongo.bson.to.list(b, simplify = FALSE)) 34 | # heterogeneous types of array values 35 | print(mongo.bson.to.list(mongo.bson.from.list(list(x = list('a', 1))), simplify = TRUE)) 36 | # identical to call with simplify = F 37 | print(mongo.bson.to.list(mongo.bson.from.list(list(x = list('a', 1))), simplify = FALSE)) 38 | } 39 | \seealso{ 40 | \code{\link{mongo.bson.from.list}}, \code{\link{mongo.bson.to.Robject}},\cr \link{mongo.bson}. 41 | } 42 | 43 | -------------------------------------------------------------------------------- /man/mongo.gridfs.find.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.gridfs.find} 3 | \alias{mongo.gridfs.find} 4 | \title{Find a GridFS file} 5 | \usage{ 6 | mongo.gridfs.find(gridfs, query) 7 | } 8 | \arguments{ 9 | \item{gridfs}{A (\link{mongo.gridfs}) object.} 10 | 11 | \item{query}{(string) The name of the GridFS file to locate. 12 | 13 | This parameter may also be a \link{mongo.bson} query object and is used to 14 | search the GridFS "files" collection documents for matches. Alternately, 15 | \code{query} may be a list which will be converted to a mongo.bson object by 16 | \code{\link{mongo.bson.from.list}()}.} 17 | } 18 | \value{ 19 | NULL, if not found; otherwise, a \link{mongo.gridfile} object 20 | corresponding to the found GridFS file. 21 | } 22 | \description{ 23 | Find a GridFS file and return a \link{mongo.gridfile} object used for 24 | further operations on it 25 | } 26 | \examples{ 27 | mongo <- mongo.create() 28 | if (mongo.is.connected(mongo)) { 29 | gridfs <- mongo.gridfs.create(mongo, "grid") 30 | 31 | gf <- mongo.gridfs.find(gridfs, "test.dat") 32 | print(mongo.gridfile.get.length(gf)) 33 | 34 | # find a GridFS file uploaded midnight July 4, 2008 35 | buf <- mongo.bson.buffer.create() 36 | mongo.bson.buffer.append(buf, "uploadDate", 37 | strptime("07-04-2008", "\%m-\%d-\%Y")) 38 | query <- mongo.bson.from.buffer(buf) 39 | gf <- mongo.gridfs.find(gridfs, query) 40 | 41 | if (!is.null(gf)) 42 | print(mongo.gridfile.get.filename(gf)) 43 | 44 | mongo.gridfs.destroy(gridfs) 45 | } 46 | } 47 | \seealso{ 48 | \link{mongo.gridfile},\cr 49 | \code{\link{mongo.gridfile.get.filename}},\cr \link{mongo.gridfs}. 50 | } 51 | 52 | -------------------------------------------------------------------------------- /man/mongo.get.server.err.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.get.server.err} 3 | \alias{mongo.get.server.err} 4 | \title{Retrieve an server error code from a mongo connection object} 5 | \usage{ 6 | mongo.get.server.err(mongo) 7 | } 8 | \arguments{ 9 | \item{mongo}{(\link{mongo}) a mongo connection object.} 10 | } 11 | \value{ 12 | (integer) Server error code 13 | } 14 | \description{ 15 | Retrieve an server error code from a mongo connection object. 16 | } 17 | \details{ 18 | \code{\link{mongo.find}()}, \code{\link{mongo.find.one}()}, 19 | \code{\link{mongo.index.create}()} set or clear this error code depending on 20 | whether they are successful or not. 21 | 22 | \code{\link{mongo.get.last.err}()} and \code{\link{mongo.get.prev.err}()} 23 | both set or clear this error code according to what the server reports. 24 | } 25 | \examples{ 26 | mongo <- mongo.create() 27 | if (mongo.is.connected(mongo)) { 28 | # construct a query containing invalid operator 29 | buf <- mongo.bson.buffer.create() 30 | mongo.bson.buffer.start.object(buf, "age") 31 | mongo.bson.buffer.append(buf, "$bad", 1L) 32 | mongo.bson.buffer.finish.object(buf) 33 | query <- mongo.bson.from.buffer(buf) 34 | 35 | result <- mongo.find.one(mongo, "test.people", query) 36 | if (is.null(result)) { 37 | print(mongo.get.server.err.string(mongo)) 38 | print(mongo.get.server.err(mongo)) 39 | } 40 | } 41 | } 42 | \seealso{ 43 | \code{\link{mongo.get.server.err.string}},\cr 44 | \code{\link{mongo.get.last.err}},\cr \code{\link{mongo.get.prev.err}},\cr 45 | \code{\link{mongo.find}},\cr \code{\link{mongo.find.one}},\cr 46 | \code{\link{mongo.index.create}},\cr \link{mongo}. 47 | } 48 | 49 | -------------------------------------------------------------------------------- /man/mongo.timestamp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{class} 3 | \name{mongo.timestamp} 4 | \alias{mongo.timestamp} 5 | \title{The mongo.timestamp class} 6 | \description{ 7 | Objects of class "mongo.timestamp" are an extension of the POSIXct class. 8 | They have their increment value stored in the "increment" attribute of the 9 | object. 10 | } 11 | \details{ 12 | See \url{http://www.mongodb.org/display/DOCS/Timestamp+Data+Type} 13 | 14 | mongo.timestamp objects have "mongo.timestamp", "POSIXct" & "POSIXt" as 15 | their class so that \code{\link{mongo.bson.buffer.append}()} may detect them 16 | and append the appropriate BSON code-typed value to a buffer. 17 | 18 | These mongo.timestamp values may also be present in a list and will be 19 | handled properly by \code{\link{mongo.bson.buffer.append.list}()} and 20 | \code{\link{mongo.bson.from.list}()}. 21 | } 22 | \examples{ 23 | mongo <- mongo.create() 24 | if (mongo.is.connected(mongo)) { 25 | buf <- mongo.bson.buffer.create() 26 | # special Null timestamp -- automatically filled in 27 | # if one of first two fields in a record 28 | ts <- mongo.timestamp.create(0,0) 29 | mongo.bson.buffer.append(buf, "InsertTime", ts) 30 | mongo.bson.buffer.append(buf, "name", "Joe") 31 | b <- mongo.bson.from.buffer(buf) 32 | mongo.insert(mongo, "test.people", b) 33 | 34 | # create using a POSIXlt 35 | ts <- mongo.timestamp.create(strptime("05-12-2012", 36 | "\%m-\%d-\%Y"), increment=1) 37 | } 38 | } 39 | \seealso{ 40 | \code{\link{mongo.timestamp.create}},\cr 41 | \code{\link{mongo.bson.buffer.append}},\cr 42 | \code{\link{mongo.bson.buffer.append.list}},\cr \link{mongo.bson.buffer},\cr 43 | \link{mongo.bson}. 44 | } 45 | 46 | -------------------------------------------------------------------------------- /man/mongo.get.server.err.string.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.get.server.err.string} 3 | \alias{mongo.get.server.err.string} 4 | \title{Retrieve an server error code from a mongo connection object} 5 | \usage{ 6 | mongo.get.server.err.string(mongo) 7 | } 8 | \arguments{ 9 | \item{mongo}{(\link{mongo}) a mongo connection object.} 10 | } 11 | \value{ 12 | (string) Server error string 13 | } 14 | \description{ 15 | Retrieve an server error string from a mongo connection object. 16 | } 17 | \details{ 18 | \code{\link{mongo.find}()}, \code{\link{mongo.find.one}()}, 19 | \code{\link{mongo.index.create}()} set or clear this error string depending 20 | on whether they are successful or not. 21 | 22 | \code{\link{mongo.get.last.err}()} and \code{\link{mongo.get.prev.err}()} 23 | both set or clear this error string according to what the server reports. 24 | } 25 | \examples{ 26 | mongo <- mongo.create() 27 | if (mongo.is.connected(mongo)) { 28 | # construct a query containing invalid operator 29 | buf <- mongo.bson.buffer.create() 30 | mongo.bson.buffer.start.object(buf, "age") 31 | mongo.bson.buffer.append(buf, "$bad", 1L) 32 | mongo.bson.buffer.finish.object(buf) 33 | query <- mongo.bson.from.buffer(buf) 34 | 35 | result <- mongo.find.one(mongo, "test.people", query) 36 | if (is.null(result)) { 37 | print(mongo.get.server.err(mongo)) 38 | print(mongo.get.server.err.string(mongo)) 39 | } 40 | } 41 | } 42 | \seealso{ 43 | \code{\link{mongo.get.server.err}},\cr 44 | \code{\link{mongo.get.last.err}},\cr \code{\link{mongo.get.prev.err}},\cr 45 | \code{\link{mongo.find}},\cr \code{\link{mongo.find.one}},\cr 46 | \code{\link{mongo.index.create}},\cr \link{mongo}. 47 | } 48 | 49 | -------------------------------------------------------------------------------- /man/mongo.gridfile.get.chunk.count.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.gridfile.get.chunk.count} 3 | \alias{mongo.gridfile.get.chunk.count} 4 | \title{Get the chunk count of a mongo.gridfile} 5 | \usage{ 6 | mongo.gridfile.get.chunk.count(gridfile) 7 | } 8 | \arguments{ 9 | \item{gridfile}{A (\link{mongo.gridfile}) object.} 10 | } 11 | \value{ 12 | (integer) The chunk count of \code{gridfile} 13 | } 14 | \description{ 15 | Get the chunk count of a \link{mongo.gridfile}. This is the number of chunks 16 | into which the gridfile is broken up on the server. 17 | } 18 | \examples{ 19 | mongo <- mongo.create() 20 | if (mongo.is.connected(mongo)) { 21 | gridfs <- mongo.gridfs.create(mongo, "grid") 22 | mongo.gridfs.store.file(gridfs, "tests/test.R", "test.R") 23 | 24 | gf <- mongo.gridfs.find(gridfs, "test.R") 25 | if( !is.null(gf)){ 26 | print(mongo.gridfile.get.chunk.count(gf)) 27 | 28 | mongo.gridfile.destroy(gf) 29 | } 30 | mongo.gridfs.destroy(gridfs) 31 | } 32 | } 33 | \seealso{ 34 | \code{\link{mongo.gridfs}},\cr \code{\link{mongo.gridfs.find}},\cr 35 | \link{mongo.gridfile},\cr \code{\link{mongo.gridfile.get.descriptor}},\cr 36 | \code{\link{mongo.gridfile.get.filename}},\cr 37 | \code{\link{mongo.gridfile.get.length}},\cr 38 | \code{\link{mongo.gridfile.get.chunk.size}},\cr 39 | \code{\link{mongo.gridfile.get.content.type}},\cr 40 | \code{\link{mongo.gridfile.get.upload.date}},\cr 41 | \code{\link{mongo.gridfile.get.md5}},\cr 42 | \code{\link{mongo.gridfile.get.metadata}},\cr 43 | \code{\link{mongo.gridfile.get.chunk}},\cr 44 | \code{\link{mongo.gridfile.get.chunks}},\cr 45 | \code{\link{mongo.gridfile.read}},\cr \code{\link{mongo.gridfile.seek}},\cr 46 | \code{\link{mongo.gridfile.pipe}}. 47 | } 48 | 49 | -------------------------------------------------------------------------------- /man/mongo.bson.buffer.append.time.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.buffer.append.time} 3 | \alias{mongo.bson.buffer.append.time} 4 | \title{Append a time value into a mongo.bson.buffer} 5 | \usage{ 6 | mongo.bson.buffer.append.time(buf, name, time) 7 | } 8 | \arguments{ 9 | \item{buf}{(\link{mongo.bson.buffer}) The buffer object to which to append.} 10 | 11 | \item{name}{(string) The name (key) of the field appended to the buffer.} 12 | 13 | \item{time}{(integer) A time value. This may also be an object of\cr class 14 | "POSIXct", "POSIXlt" or "mongo.timestamp".} 15 | } 16 | \value{ 17 | TRUE if successful; otherwise, FALSE if an error occured appending 18 | the data. 19 | } 20 | \description{ 21 | Append a date/time value into a \link{mongo.bson.buffer}. 22 | } 23 | \details{ 24 | BSON has a special field type to indicate a date/time; these are 64-bit 25 | values. 26 | 27 | However, R has a 'standard' object of class "POSIXct" used to represent 28 | date/time values, such as that returned by Sys.time(). Internally these are 29 | a 32-bit integer number of milliseconds since midnight January 1, 1970. On 30 | January 19, 2038, 32-bit versions of the the Unix time stamp will cease to 31 | work, as it will overflow the largest value that can be held in a signed 32 | 32-bit number. At such time, many applications, including R and this driver, 33 | will need to address that issue. 34 | } 35 | \examples{ 36 | buf <- mongo.bson.buffer.create() 37 | mongo.bson.buffer.append.time(buf, "Now", Sys.time()) 38 | b <- mongo.bson.from.buffer(buf) 39 | } 40 | \seealso{ 41 | \link{mongo.timestamp},\cr \code{\link{mongo.timestamp.create}},\cr 42 | \code{\link{mongo.bson.buffer.append}},\cr \link{mongo.bson.buffer},\cr 43 | \link{mongo.bson}. 44 | } 45 | 46 | -------------------------------------------------------------------------------- /man/mongo.reset.err.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.reset.err} 3 | \alias{mongo.reset.err} 4 | \title{Retrieve an server error code from a mongo connection object} 5 | \usage{ 6 | mongo.reset.err(mongo, db) 7 | } 8 | \arguments{ 9 | \item{mongo}{(\link{mongo}) a mongo connection object.} 10 | 11 | \item{db}{(string) The name of the database on which to reset the error 12 | status.} 13 | } 14 | \description{ 15 | Send a "reset error" command to the server, it also resets the values 16 | returned by\cr \code{\link{mongo.get.server.err}()} and 17 | \code{\link{mongo.get.server.err.string}()}. 18 | } 19 | \examples{ 20 | mongo <- mongo.create() 21 | if (mongo.is.connected(mongo)) { 22 | 23 | # try adding a duplicate record when index doesn't allow this 24 | 25 | db <- "test" 26 | ns <- "test.people" 27 | mongo.index.create(mongo, ns, '{"name":1}', mongo.index.unique) 28 | 29 | buf <- mongo.bson.buffer.create() 30 | mongo.bson.buffer.append(buf, "name", "John") 31 | mongo.bson.buffer.append(buf, "age", 22L) 32 | b <- mongo.bson.from.buffer(buf) 33 | mongo.insert(mongo, ns, b); 34 | 35 | buf <- mongo.bson.buffer.create() 36 | mongo.bson.buffer.append(buf, "name", "John") 37 | mongo.bson.buffer.append(buf, "age", 27L) 38 | b <- mongo.bson.from.buffer(buf) 39 | mongo.insert(mongo, ns, b); 40 | 41 | err <- mongo.get.last.err(mongo, db) 42 | print(mongo.get.server.err(mongo)) 43 | print(mongo.get.server.err.string(mongo)) 44 | mongo.reset.err(mongo, db) 45 | } 46 | } 47 | \seealso{ 48 | \code{\link{mongo.get.server.err}},\cr 49 | \code{\link{mongo.get.server.err.string}},\cr 50 | \code{\link{mongo.get.last.err}},\cr \code{\link{mongo.get.prev.err}},\cr 51 | \link{mongo}. 52 | } 53 | 54 | -------------------------------------------------------------------------------- /man/mongo.gridfile.get.content.type.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.gridfile.get.content.type} 3 | \alias{mongo.gridfile.get.content.type} 4 | \title{Get the content type of a mongo.gridfile} 5 | \usage{ 6 | mongo.gridfile.get.content.type(gridfile) 7 | } 8 | \arguments{ 9 | \item{gridfile}{A (\link{mongo.gridfile}) object.} 10 | } 11 | \value{ 12 | (string) The content.type (remote name) of \code{gridfile}. This may 13 | be an empty string if no content type is associated with the gridfile. 14 | } 15 | \description{ 16 | Get the MIME content type of a \link{mongo.gridfile}. 17 | } 18 | \examples{ 19 | mongo <- mongo.create() 20 | if (mongo.is.connected(mongo)) { 21 | gridfs <- mongo.gridfs.create(mongo, "grid") 22 | mongo.gridfs.store.file(gridfs, "tests/test.R", "test.R") 23 | 24 | gf <- mongo.gridfs.find(gridfs, "test.R") 25 | if( !is.null(gf)){ 26 | print(mongo.gridfile.get.content.type(gf)) 27 | 28 | mongo.gridfile.destroy(gf) 29 | } 30 | mongo.gridfs.destroy(gridfs) 31 | } 32 | } 33 | \seealso{ 34 | \code{\link{mongo.gridfs}},\cr \code{\link{mongo.gridfs.find}},\cr 35 | \link{mongo.gridfile},\cr \code{\link{mongo.gridfile.get.descriptor}},\cr 36 | \code{\link{mongo.gridfile.get.filename}},\cr 37 | \code{\link{mongo.gridfile.get.length}},\cr 38 | \code{\link{mongo.gridfile.get.chunk.size}},\cr 39 | \code{\link{mongo.gridfile.get.chunk.count}},\cr 40 | \code{\link{mongo.gridfile.get.upload.date}},\cr 41 | \code{\link{mongo.gridfile.get.md5}},\cr 42 | \code{\link{mongo.gridfile.get.metadata}},\cr 43 | \code{\link{mongo.gridfile.get.chunk}},\cr 44 | \code{\link{mongo.gridfile.get.chunks}},\cr 45 | \code{\link{mongo.gridfile.read}},\cr \code{\link{mongo.gridfile.seek}},\cr 46 | \code{\link{mongo.gridfile.pipe}}. 47 | } 48 | 49 | -------------------------------------------------------------------------------- /man/mongo.gridfile.writer.write.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.gridfile.writer.write} 3 | \alias{mongo.gridfile.writer.write} 4 | \title{Write raw data to a buffered GridFS file} 5 | \usage{ 6 | mongo.gridfile.writer.write(gfw, raw) 7 | } 8 | \arguments{ 9 | \item{gfw}{A (\link{mongo.gridfile.writer}) object.} 10 | 11 | \item{raw}{(raw) The data to write to the GridFS file.} 12 | } 13 | \description{ 14 | Write raw data to a buffered GridFS file. The data is buffered and sent to 15 | the server in 256k chunks as it accumulates. 16 | } 17 | \details{ 18 | This function only handles the RAW type. Use \code{writeBin()} as necessary 19 | to pack your data appropriately for storage. See the examples and R's 20 | documentation on \code{writeBin()}. 21 | 22 | Use \code{\link{mongo.gridfs.store}()} when you only need to write one data 23 | packet as a complete GridFS file. 24 | } 25 | \examples{ 26 | mongo <- mongo.create() 27 | if (mongo.is.connected(mongo)) { 28 | gridfs <- mongo.gridfs.create(mongo, "grid") 29 | 30 | gfw <- mongo.gridfile.writer.create(gridfs, "test.dat") 31 | 32 | # store 4 bytes 33 | mongo.gridfile.writer.write(gfw, charToRaw("test")) 34 | 35 | # store string & LF plus 0-byte terminator 36 | buf <- writeBin("Test\\n", as.raw(1)) 37 | mongo.gridfile.writer.write(gfw, buf) 38 | 39 | # store PI as a float 40 | buf <- writeBin(3.1415926, as.raw(1), size=4, endian="little") 41 | mongo.gridfile.writer.write(gfw, buf) 42 | 43 | mongo.gridfile.writer.finish(gfw) 44 | 45 | mongo.gridfs.destroy(gridfs) 46 | } 47 | } 48 | \seealso{ 49 | \link{mongo.gridfs},\cr 50 | \code{\link{mongo.gridfile.writer.create}},\cr 51 | \link{mongo.gridfile.writer},\cr \code{\link{mongo.gridfile.writer.finish}}. 52 | } 53 | 54 | -------------------------------------------------------------------------------- /man/mongo.bson.buffer.start.object.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.buffer.start.object} 3 | \alias{mongo.bson.buffer.start.object} 4 | \title{Start a subobject within a mongo.bson.buffer} 5 | \usage{ 6 | mongo.bson.buffer.start.object(buf, name) 7 | } 8 | \arguments{ 9 | \item{buf}{(\link{mongo.bson.buffer}) The buffer object to which to append.} 10 | 11 | \item{name}{(string) The name (key) of the subobject to be appended to the 12 | buffer.} 13 | } 14 | \value{ 15 | TRUE if successful; otherwise, FALSE if an error occured appending 16 | the data. 17 | } 18 | \description{ 19 | BSON documents may themselves contain nested documents. Call this function 20 | to start a subobject within a \link{mongo.bson.buffer}. 21 | } 22 | \details{ 23 | \code{\link{mongo.bson.buffer.finish.object}()} must be called when finsihed 24 | appending subfields.\cr (\code{mongo.bson.buffer.start.object()}, 25 | \code{mongo.bson.buffer.start.array()})\cr and 26 | \code{mongo.bson.buffer.finish.object()} may be called in a stackwise (LIFO) 27 | order to further nest documents and arrays. 28 | } 29 | \examples{ 30 | buf <- mongo.bson.buffer.create() 31 | mongo.bson.buffer.start.object(buf, "name") 32 | mongo.bson.buffer.append(buf, "first", "Jeff") 33 | mongo.bson.buffer.append(buf, "last", "Davis") 34 | mongo.bson.buffer.finish.object(buf) 35 | mongo.bson.buffer.append(buf, "city", "Toronto") 36 | b <- mongo.bson.from.buffer(buf) 37 | 38 | # the above produces a BSON object of the form: 39 | # { "name" : { "first" : "Jeff", "last" : "Davis" }, "city" : "Toronto" } 40 | } 41 | \seealso{ 42 | \link{mongo.bson},\cr \link{mongo.bson.buffer},\cr 43 | \code{\link{mongo.bson.buffer.finish.object}},\cr 44 | \code{\link{mongo.bson.buffer.start.array}},\cr 45 | \code{\link{mongo.bson.buffer.append}}. 46 | } 47 | 48 | -------------------------------------------------------------------------------- /man/mongo.gridfile.writer.create.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.gridfile.writer.create} 3 | \alias{mongo.gridfile.writer.create} 4 | \title{Create a mongo.gridfile.writer object} 5 | \usage{ 6 | mongo.gridfile.writer.create(gridfs, remotename, contenttype = "") 7 | } 8 | \arguments{ 9 | \item{gridfs}{A (\link{mongo.gridfs}) object.} 10 | 11 | \item{remotename}{(string) The name the file will be known as within the 12 | GridFS.} 13 | 14 | \item{contenttype}{(string) Optional MIME content type.} 15 | } 16 | \value{ 17 | (\link{mongo.gridfile.writer}) The object to be used for writing to 18 | the GridFS file. 19 | } 20 | \description{ 21 | Create a \link{mongo.gridfile.writer} object used to buffer many writes to a 22 | single GridFS file. Once the mongo.gridfile.writer is created, use 23 | \code{\link{mongo.gridfile.writer.write}()} to write data to the buffered 24 | GridFS file and \code{\link{mongo.gridfile.writer.finish}()} when done. 25 | } 26 | \examples{ 27 | mongo <- mongo.create() 28 | if (mongo.is.connected(mongo)) { 29 | gridfs <- mongo.gridfs.create(mongo, "grid") 30 | 31 | gfw <- mongo.gridfile.writer.create(gridfs, "test.dat") 32 | 33 | # store 4 bytes 34 | mongo.gridfile.writer.write(gfw, charToRaw("test")) 35 | 36 | # store string & LF plus 0-byte terminator 37 | buf <- writeBin("Test\\n", as.raw(1)) 38 | mongo.gridfile.writer.write(gfw, buf) 39 | 40 | # store PI as a float 41 | buf <- writeBin(3.1415926, as.raw(1), size=4, endian="little") 42 | mongo.gridfile.writer.write(gfw, buf) 43 | 44 | mongo.gridfile.writer.finish(gfw) 45 | mongo.gridfs.destroy(gridfs) 46 | } 47 | } 48 | \seealso{ 49 | \link{mongo.gridfs},\cr \code{\link{mongo.gridfs.create}},\cr 50 | \code{\link{mongo.gridfile.writer.write}},\cr 51 | \code{\link{mongo.gridfile.writer.finish}}. 52 | } 53 | 54 | -------------------------------------------------------------------------------- /man/mongo.timestamp.create.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.timestamp.create} 3 | \alias{mongo.timestamp.create} 4 | \title{Create a mongo.timestamp object} 5 | \usage{ 6 | mongo.timestamp.create(time, increment) 7 | } 8 | \arguments{ 9 | \item{time}{(integer) date/time value (milliseconds since UTC epoch). 10 | 11 | This may also be a "POSIXct" or "POSIXlt" class object.} 12 | 13 | \item{increment}{increment ordinal} 14 | } 15 | \value{ 16 | A \link{mongo.timestamp} object 17 | } 18 | \description{ 19 | Create a \link{mongo.timestamp} object for appending to a buffer with\cr 20 | \code{\link{mongo.bson.buffer.append.timestamp}()} or 21 | \code{\link{mongo.bson.buffer.append}()}, or for embedding in a list such 22 | that \code{\link{mongo.bson.buffer.append.list}()} will properly insert a 23 | timestamp value into the mongo.bson.buffer object. 24 | } 25 | \details{ 26 | See \url{http://www.mongodb.org/display/DOCS/Timestamp+Data+Type} 27 | } 28 | \examples{ 29 | mongo <- mongo.create() 30 | if (mongo.is.connected(mongo)) { 31 | buf <- mongo.bson.buffer.create() 32 | # special Null timestamp -- automatically filled in 33 | # if one of first two fields in a record 34 | ts <- mongo.timestamp.create(0,0) 35 | mongo.bson.buffer.append(buf, "InsertTime", ts) 36 | mongo.bson.buffer.append(buf, "name", "Joe") 37 | b <- mongo.bson.from.buffer(buf) 38 | mongo.insert(mongo, "test.people", b) 39 | 40 | # create using a POSIXlt 41 | ts <- mongo.timestamp.create(strptime("05-12-2012", 42 | "\%m-\%d-\%Y"), increment=1) 43 | } 44 | } 45 | \seealso{ 46 | \link{mongo.timestamp},\cr 47 | \code{\link{mongo.bson.buffer.append}},\cr 48 | \code{\link{mongo.bson.buffer.append.time}},\cr 49 | \code{\link{mongo.bson.buffer.append.list}},\cr \link{mongo.bson.buffer},\cr 50 | \link{mongo.bson}. 51 | } 52 | 53 | -------------------------------------------------------------------------------- /man/mongo.gridfile.pipe.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.gridfile.pipe} 3 | \alias{mongo.gridfile.pipe} 4 | \title{Pipe a mongo.gridfile to an R connection} 5 | \usage{ 6 | mongo.gridfile.pipe(gridfile, con) 7 | } 8 | \arguments{ 9 | \item{gridfile}{A (\link{mongo.gridfile}) object.} 10 | 11 | \item{con}{(connection) An R connection object.} 12 | } 13 | \description{ 14 | Pipe a mongo.gridfile to an R connection. This outputs the entire GridFS 15 | file to a connection. If the connection is open, it must be in binary output 16 | mode; otherwise, the connection is opened in binary output mode and closed 17 | afterwards. 18 | } 19 | \examples{ 20 | mongo <- mongo.create() 21 | if (mongo.is.connected(mongo)) { 22 | gridfs <- mongo.gridfs.create(mongo, "grid") 23 | mongo.gridfs.store.file(gridfs, "tests/test.R", "test.R") 24 | 25 | gf <- mongo.gridfs.find(gridfs, "test.R") 26 | if (!is.null(gf)) { 27 | f <- file("mongodb_copy.pdf") 28 | mongo.gridfile.pipe(gf, f) 29 | 30 | mongo.gridfile.destroy(gf) 31 | } 32 | 33 | mongo.gridfs.destroy(gridfs) 34 | } 35 | } 36 | \seealso{ 37 | \code{\link{mongo.gridfs}},\cr \code{\link{mongo.gridfs.find}},\cr 38 | \link{mongo.gridfile},\cr \code{\link{mongo.gridfile.get.descriptor}},\cr 39 | \code{\link{mongo.gridfile.get.filename}},\cr 40 | \code{\link{mongo.gridfile.get.length}},\cr 41 | \code{\link{mongo.gridfile.get.chunk.size}},\cr 42 | \code{\link{mongo.gridfile.get.chunk.count}},\cr 43 | \code{\link{mongo.gridfile.get.content.type}},\cr 44 | \code{\link{mongo.gridfile.get.upload.date}},\cr 45 | \code{\link{mongo.gridfile.get.md5}},\cr 46 | \code{\link{mongo.gridfile.get.metadata}},\cr 47 | \code{\link{mongo.gridfile.get.chunk}},\cr 48 | \code{\link{mongo.gridfile.get.chunks}},\cr 49 | \code{\link{mongo.gridfile.read}},\cr \code{\link{mongo.gridfile.seek}}. 50 | } 51 | 52 | -------------------------------------------------------------------------------- /man/mongo.gridfs.store.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.gridfs.store} 3 | \alias{mongo.gridfs.store} 4 | \title{Store raw data as a file in a GridFS} 5 | \usage{ 6 | mongo.gridfs.store(gridfs, raw, remotename, contenttype = "") 7 | } 8 | \arguments{ 9 | \item{gridfs}{A (\link{mongo.gridfs}) object.} 10 | 11 | \item{raw}{(raw) The data to store on the server.} 12 | 13 | \item{remotename}{(string) The name the file will be known as within the 14 | GridFS.} 15 | 16 | \item{contenttype}{(string) Optional MIME content type.} 17 | } 18 | \value{ 19 | TRUE, if successful; FALSE, if an error occured during the 20 | operation. 21 | } 22 | \description{ 23 | Store raw data as a file to a GridFS on a MongoDB server. This function 24 | stores the entire piece of data file on the server, breaking it up into 256K 25 | chunks as necessary. 26 | } 27 | \details{ 28 | This function only handles the RAW type. Use \code{writeBin()} as necessary 29 | to pack your data appropriately for storage. See the examples and R's 30 | documentation on \code{writeBin()}. 31 | 32 | Use \link{mongo.gridfile.writer} when you need to buffer many writes to a 33 | GridFS file. 34 | } 35 | \examples{ 36 | mongo <- mongo.create() 37 | if (mongo.is.connected(mongo)) { 38 | gridfs <- mongo.gridfs.create(mongo, "grid") 39 | # store 4 bytes 40 | mongo.gridfs.store(gridfs, charToRaw("test"), "test4.dat") 41 | 42 | # store string & LF plus 0-byte terminator 43 | buf <- writeBin("Test\\n", as.raw(1)) 44 | mongo.gridfs.store(gridfs, buf, "test6.dat") 45 | 46 | # store PI as a float 47 | buf <- writeBin(3.1415926, as.raw(1), size=4, endian="little") 48 | mongo.gridfs.store(gridfs, buf, "PI.dat") 49 | 50 | mongo.gridfs.destroy(gridfs) 51 | } 52 | } 53 | \seealso{ 54 | \link{mongo.gridfs},\cr \code{\link{mongo.gridfs.create}},\cr 55 | \code{\link{mongo.gridfs.remove.file}}. 56 | } 57 | 58 | -------------------------------------------------------------------------------- /man/mongo.gridfile.get.descriptor.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.gridfile.get.descriptor} 3 | \alias{mongo.gridfile.get.descriptor} 4 | \title{Get the descriptor of a mongo.gridfile} 5 | \usage{ 6 | mongo.gridfile.get.descriptor(gridfile) 7 | } 8 | \arguments{ 9 | \item{gridfile}{A (\link{mongo.gridfile}) object.} 10 | } 11 | \value{ 12 | (\link{mongo.bson}) The descriptor of \code{gridfile}. 13 | } 14 | \description{ 15 | Get the descriptor of a \link{mongo.gridfile}. This descriptor is the 16 | document describing the given gridfile as stored on the MongoDB server in 17 | the 'files' collection of the GridFS . 18 | } 19 | \details{ 20 | See \url{http://www.mongodb.org/display/DOCS/GridFS+Specification}. 21 | } 22 | \examples{ 23 | mongo <- mongo.create() 24 | if (mongo.is.connected(mongo)) { 25 | gridfs <- mongo.gridfs.create(mongo, "grid") 26 | mongo.gridfs.store.file(gridfs, "tests/test.R", "test.R") 27 | 28 | gf <- mongo.gridfs.find(gridfs, "test.R") 29 | if( !is.null(gf)){ 30 | print(mongo.gridfile.get.descriptor(gf)) 31 | 32 | mongo.gridfile.destroy(gf) 33 | } 34 | mongo.gridfs.destroy(gridfs) 35 | } 36 | } 37 | \seealso{ 38 | \code{\link{mongo.gridfs}},\cr \code{\link{mongo.gridfs.find}},\cr 39 | \link{mongo.gridfile},\cr \code{\link{mongo.gridfile.get.filename}},\cr 40 | \code{\link{mongo.gridfile.get.length}},\cr 41 | \code{\link{mongo.gridfile.get.chunk.size}},\cr 42 | \code{\link{mongo.gridfile.get.chunk.count}},\cr 43 | \code{\link{mongo.gridfile.get.content.type}},\cr 44 | \code{\link{mongo.gridfile.get.upload.date}},\cr 45 | \code{\link{mongo.gridfile.get.md5}},\cr 46 | \code{\link{mongo.gridfile.get.metadata}},\cr 47 | \code{\link{mongo.gridfile.get.chunk}},\cr 48 | \code{\link{mongo.gridfile.get.chunks}},\cr 49 | \code{\link{mongo.gridfile.read}},\cr \code{\link{mongo.gridfile.seek}},\cr 50 | \code{\link{mongo.gridfile.pipe}}. 51 | } 52 | 53 | -------------------------------------------------------------------------------- /man/mongo.gridfile.seek.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.gridfile.seek} 3 | \alias{mongo.gridfile.seek} 4 | \title{Seek to a position in a mongo.gridfile} 5 | \usage{ 6 | mongo.gridfile.seek(gridfile, offset) 7 | } 8 | \arguments{ 9 | \item{gridfile}{A (\link{mongo.gridfile}) object.} 10 | 11 | \item{offset}{(as.double) The position to which to seek.} 12 | } 13 | \value{ 14 | (double) The position set. This may be at the length of the GridFS 15 | file if \code{offset} was greater than that. 16 | } 17 | \description{ 18 | Seek to a position in a \link{mongo.gridfile}.\cr This sets the position at 19 | which the next \code{\link{mongo.gridfile.read}()} will start. 20 | } 21 | \examples{ 22 | mongo <- mongo.create() 23 | if (mongo.is.connected(mongo)) { 24 | gridfs <- mongo.gridfs.create(mongo, "grid") 25 | mongo.gridfs.store.file(gridfs, "tests/test.R", "test.R") 26 | 27 | gf <- mongo.gridfs.find(gridfs, "test.R") 28 | if( !is.null(gf)){ 29 | mongo.gridfile.seek(gf, 256*256*5) 30 | data <- mongo.gridfile.read(gf, 16384) 31 | 32 | mongo.gridfile.destroy(gf) 33 | } 34 | mongo.gridfs.destroy(gridfs) 35 | } 36 | } 37 | \seealso{ 38 | \code{\link{mongo.gridfs}},\cr \code{\link{mongo.gridfs.find}},\cr 39 | \link{mongo.gridfile},\cr \code{\link{mongo.gridfile.get.descriptor}},\cr 40 | \code{\link{mongo.gridfile.get.filename}},\cr 41 | \code{\link{mongo.gridfile.get.length}},\cr 42 | \code{\link{mongo.gridfile.get.chunk.size}},\cr 43 | \code{\link{mongo.gridfile.get.chunk.count}},\cr 44 | \code{\link{mongo.gridfile.get.content.type}},\cr 45 | \code{\link{mongo.gridfile.get.upload.date}},\cr 46 | \code{\link{mongo.gridfile.get.md5}},\cr 47 | \code{\link{mongo.gridfile.get.metadata}},\cr 48 | \code{\link{mongo.gridfile.get.chunk}},\cr 49 | \code{\link{mongo.gridfile.get.chunks}},\cr 50 | \code{\link{mongo.gridfile.read}},\cr \code{\link{mongo.gridfile.pipe}}. 51 | } 52 | 53 | -------------------------------------------------------------------------------- /man/mongo.gridfile.get.filename.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.gridfile.get.filename} 3 | \alias{mongo.gridfile.get.filename} 4 | \title{Get the filename of a mongo.gridfile} 5 | \usage{ 6 | mongo.gridfile.get.filename(gridfile) 7 | } 8 | \arguments{ 9 | \item{gridfile}{A (\link{mongo.gridfile}) object.} 10 | } 11 | \value{ 12 | (string) The filename (remote name) of \code{gridfile} 13 | } 14 | \description{ 15 | Get the filename of a \link{mongo.gridfile}. This is the 'remote name' that 16 | is used identify the file on the server. 17 | } 18 | \examples{ 19 | mongo <- mongo.create() 20 | if (mongo.is.connected(mongo)) { 21 | gridfs <- mongo.gridfs.create(mongo, "grid") 22 | 23 | # find a GridFS file uploaded midnight July 4, 2008 24 | buf <- mongo.bson.buffer.create() 25 | mongo.bson.buffer.append(buf, "uploadDate", 26 | strptime("07-04-2008", "\%m-\%d-\%Y")) 27 | query <- mongo.bson.from.buffer(buf) 28 | 29 | gf <- mongo.gridfs.find(gridfs, query) 30 | if (!is.null(gf)) { 31 | print(mongo.gridfile.get.filename(gf)) 32 | 33 | mongo.gridfile.destroy(gf) 34 | } 35 | mongo.gridfs.destroy(gridfs) 36 | } 37 | } 38 | \seealso{ 39 | \code{\link{mongo.gridfs}},\cr \code{\link{mongo.gridfs.find}},\cr 40 | \link{mongo.gridfile},\cr \code{\link{mongo.gridfile.get.descriptor}},\cr 41 | \code{\link{mongo.gridfile.get.length}},\cr 42 | \code{\link{mongo.gridfile.get.chunk.size}},\cr 43 | \code{\link{mongo.gridfile.get.chunk.count}},\cr 44 | \code{\link{mongo.gridfile.get.content.type}},\cr 45 | \code{\link{mongo.gridfile.get.upload.date}},\cr 46 | \code{\link{mongo.gridfile.get.md5}},\cr 47 | \code{\link{mongo.gridfile.get.metadata}},\cr 48 | \code{\link{mongo.gridfile.get.chunk}},\cr 49 | \code{\link{mongo.gridfile.get.chunks}},\cr 50 | \code{\link{mongo.gridfile.read}},\cr \code{\link{mongo.gridfile.seek}},\cr 51 | \code{\link{mongo.gridfile.pipe}}. 52 | } 53 | 54 | -------------------------------------------------------------------------------- /man/mongo.gridfile.get.metadata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.gridfile.get.metadata} 3 | \alias{mongo.gridfile.get.metadata} 4 | \title{Get the metadata of a mongo.gridfile} 5 | \usage{ 6 | mongo.gridfile.get.metadata(gridfile) 7 | } 8 | \arguments{ 9 | \item{gridfile}{A (\link{mongo.gridfile}) object.} 10 | } 11 | \value{ 12 | (\link{mongo.bson}) The metadata of \code{gridfile} if present; 13 | otherwise, NULL. 14 | } 15 | \description{ 16 | Get the metadata of a \link{mongo.gridfile}. Some applications may store 17 | metadata pertaining to a GridFS file in the "metadata" field of the 18 | descriptor. (See \code{\link{mongo.gridfile.get.descriptor}()}. This 19 | function retrieves that field as a \link{mongo.bson} object. 20 | } 21 | \examples{ 22 | mongo <- mongo.create() 23 | if (mongo.is.connected(mongo)) { 24 | gridfs <- mongo.gridfs.create(mongo, "grid") 25 | mongo.gridfs.store.file(gridfs, "tests/test.R", "test.R") 26 | 27 | gf <- mongo.gridfs.find(gridfs, "test.R") 28 | if( !is.null(gf) ){ 29 | print(mongo.gridfile.get.metadata(gf)) 30 | 31 | mongo.gridfile.destroy(gf) 32 | } 33 | mongo.gridfs.destroy(gridfs) 34 | } 35 | } 36 | \seealso{ 37 | \code{\link{mongo.gridfs}},\cr \code{\link{mongo.gridfs.find}},\cr 38 | \link{mongo.gridfile},\cr \code{\link{mongo.gridfile.get.descriptor}},\cr 39 | \code{\link{mongo.gridfile.get.filename}},\cr 40 | \code{\link{mongo.gridfile.get.length}},\cr 41 | \code{\link{mongo.gridfile.get.chunk.size}},\cr 42 | \code{\link{mongo.gridfile.get.chunk.count}},\cr 43 | \code{\link{mongo.gridfile.get.content.type}},\cr 44 | \code{\link{mongo.gridfile.get.upload.date}},\cr 45 | \code{\link{mongo.gridfile.get.md5}},\cr 46 | \code{\link{mongo.gridfile.get.chunk}},\cr 47 | \code{\link{mongo.gridfile.get.chunks}},\cr 48 | \code{\link{mongo.gridfile.read}},\cr \code{\link{mongo.gridfile.seek}},\cr 49 | \code{\link{mongo.gridfile.pipe}}. 50 | } 51 | 52 | -------------------------------------------------------------------------------- /man/mongo.remove.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.remove} 3 | \alias{mongo.remove} 4 | \title{Remove records from a collection} 5 | \usage{ 6 | mongo.remove(mongo, ns, criteria = mongo.bson.empty()) 7 | } 8 | \arguments{ 9 | \item{mongo}{(\link{mongo}) a mongo connection object.} 10 | 11 | \item{ns}{(string) namespace of the collection from which to remove records.} 12 | 13 | \item{criteria}{(\link{mongo.bson}) The criteria with which to match records 14 | that are to be removed. The default of mongo.bson.empty() will cause 15 | \emph{all} records in the given collection to be removed. 16 | 17 | Alternately, \code{criteria} may be a list which will be converted to a 18 | mongo.bson object by \code{\link{mongo.bson.from.list}()}. 19 | 20 | Alternately, \code{criteria} may be a valid JSON character string which will be converted to a 21 | mongo.bson object by \code{\link{mongo.bson.from.JSON}()}.} 22 | } 23 | \description{ 24 | Remove all records from a collection that match a given criteria. 25 | } 26 | \details{ 27 | See \url{http://www.mongodb.org/display/DOCS/Removing}. 28 | } 29 | \examples{ 30 | mongo <- mongo.create() 31 | if (mongo.is.connected(mongo)) { 32 | buf <- mongo.bson.buffer.create() 33 | mongo.bson.buffer.append(buf, "name", "Jeff") 34 | criteria <- mongo.bson.from.buffer(buf) 35 | 36 | # remove all records where name is "Jeff" 37 | # from collection people in database test 38 | mongo.remove(mongo, "test.people", criteria) 39 | 40 | # remove all records from collection cars in database test 41 | mongo.remove(mongo, "test.cars") 42 | 43 | # shorthand: remove all records where name is "Fred" 44 | mongo.remove(mongo, "test.people", list(name="Fred")) 45 | } 46 | } 47 | \seealso{ 48 | \link{mongo},\cr \link{mongo.bson},\cr 49 | \code{\link{mongo.insert}},\cr \code{\link{mongo.update}},\cr 50 | \code{\link{mongo.find}},\cr \code{\link{mongo.find.one}}. 51 | } 52 | 53 | -------------------------------------------------------------------------------- /man/mongo.code.w.scope.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{class} 3 | \name{mongo.code.w.scope} 4 | \alias{mongo.code.w.scope} 5 | \title{The mongo.code.w.scope class} 6 | \description{ 7 | Objects of class "mongo.code.w.scope" are used to represent javascript code 8 | values with scopes in BSON documents. 9 | } 10 | \details{ 11 | mongo.code.w.scope objects' value is a string representing the value of the 12 | code. 13 | 14 | The scope is a \link{mongo.bson} object and is stored in the "scope" 15 | attribute of the mongo.code.w.scope object. 16 | 17 | mongo.code.w.scope objects have "mongo.code.w.scope" as their class so 18 | that\cr \code{\link{mongo.bson.buffer.append}()} may detect them and append 19 | the appropriate BSON code-typed value and scope to a buffer. 20 | 21 | These mongo.code.w.scope values may also be present in a list and will be 22 | handled properly by \code{\link{mongo.bson.buffer.append.list}()} and 23 | \code{\link{mongo.bson.from.list}()}. 24 | } 25 | \examples{ 26 | buf <- mongo.bson.buffer.create() 27 | mongo.bson.buffer.append(buf, "sv", "sx") 28 | scope <- mongo.bson.from.buffer(buf) 29 | codeWscope <- mongo.code.w.scope.create("y = x", scope) 30 | buf <- mongo.bson.buffer.create() 31 | mongo.bson.buffer.append(buf, "CodeWscope", codeWscope) 32 | lst <- list(c1 = codeWscope, One = 1) 33 | mongo.bson.buffer.append.list(buf, "listWcodeWscope", lst) 34 | b <- mongo.bson.from.buffer(buf) 35 | 36 | # the above will create a mongo.bson object of the following form: 37 | # { "CodeWscope" : (CODEWSCOPE) "y = x" 38 | # (SCOPE) { "sv" : "sx"}, 39 | # "listWcodeWscope" : { "c1" : (CODEWSCOPE) "y = x" 40 | # (SCOPE) { "sv" : "sx"} } } 41 | } 42 | \seealso{ 43 | \code{\link{mongo.code.w.scope.create}},\cr 44 | \code{\link{mongo.bson.buffer.append}},\cr 45 | \code{\link{mongo.bson.buffer.append.list}},\cr \link{mongo.bson.buffer},\cr 46 | \link{mongo.bson}. 47 | } 48 | 49 | -------------------------------------------------------------------------------- /man/mongo.cursor.destroy.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.cursor.destroy} 3 | \alias{mongo.cursor.destroy} 4 | \title{Release resources attached to a cursor} 5 | \usage{ 6 | mongo.cursor.destroy(cursor) 7 | } 8 | \arguments{ 9 | \item{cursor}{(\link{mongo.cursor}) A mongo.cursor object returned from 10 | \code{\link{mongo.find}()}.} 11 | } 12 | \value{ 13 | TRUE if successful; otherwise, FALSE (when an error occurs during 14 | sending the Kill Cursor operation to the server). in either case, the cursor 15 | should not be used for further operations. 16 | } 17 | \description{ 18 | \code{mongo.cursor.destroy(cursor)} is used to release resources attached to 19 | a cursor on both the client and server. 20 | } 21 | \details{ 22 | Note that \code{mongo.cursor.destroy(cursor)} may be called before all 23 | records of a result set are iterated through (for example, if a desired 24 | record is located in the result set). 25 | 26 | Although the 'destroy' functions in this package are called automatically by 27 | garbage collection, this one in particular should be called as soon as 28 | feasible when finished with the cursor so that server resources are freed. 29 | } 30 | \examples{ 31 | mongo <- mongo.create() 32 | if (mongo.is.connected(mongo)) { 33 | buf <- mongo.bson.buffer.create() 34 | mongo.bson.buffer.append(buf, "city", "St. Louis") 35 | query <- mongo.bson.from.buffer(buf) 36 | 37 | # Find the first 1000 records in collection people 38 | # of database test where city == "St. Louis" 39 | cursor <- mongo.find(mongo, "test.people", query, limit=1000L) 40 | # Step though the matching records and display them 41 | while (mongo.cursor.next(cursor)) 42 | print(mongo.cursor.destroy(cursor)) 43 | mongo.cursor.destroy(cursor) 44 | } 45 | } 46 | \seealso{ 47 | \code{\link{mongo.find}},\cr \link{mongo.cursor},\cr 48 | \code{\link{mongo.cursor.next}},\cr \code{\link{mongo.cursor.value}}. 49 | } 50 | 51 | -------------------------------------------------------------------------------- /man/mongo.insert.batch.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.insert.batch} 3 | \alias{mongo.insert.batch} 4 | \title{Add multiple records to a collection} 5 | \usage{ 6 | mongo.insert.batch(mongo, ns, lst) 7 | } 8 | \arguments{ 9 | \item{mongo}{(\link{mongo}) a mongo connection object.} 10 | 11 | \item{ns}{(string) namespace of the collection to which to add the record.} 12 | 13 | \item{lst}{A list of (\link{mongo.bson}) records to add.} 14 | } 15 | \value{ 16 | TRUE if the command was successfully sent to the server; otherwise, 17 | FALSE. 18 | 19 | \code{\link{mongo.get.last.err}()} may be examined to verify that the insert 20 | was successful on the server if necessary. 21 | } 22 | \description{ 23 | Add multiple records to a collection. This function eliminates some network 24 | traffic and server overhead by sending all the records in a single message. 25 | } 26 | \details{ 27 | See \url{http://www.mongodb.org/display/DOCS/Inserting}. 28 | } 29 | \examples{ 30 | mongo <- mongo.create() 31 | if (mongo.is.connected(mongo)) { 32 | ns <- "test.people" 33 | 34 | buf <- mongo.bson.buffer.create() 35 | mongo.bson.buffer.append(buf, "name", "Dave") 36 | mongo.bson.buffer.append(buf, "age", 27L) 37 | x <- mongo.bson.from.buffer(buf) 38 | 39 | buf <- mongo.bson.buffer.create() 40 | mongo.bson.buffer.append(buf, "name", "Fred") 41 | mongo.bson.buffer.append(buf, "age", 31L) 42 | y <- mongo.bson.from.buffer(buf) 43 | 44 | buf <- mongo.bson.buffer.create() 45 | mongo.bson.buffer.append(buf, "name", "Silvia") 46 | mongo.bson.buffer.append(buf, "city", 24L) 47 | z <- mongo.bson.from.buffer(buf) 48 | mongo.insert.batch(mongo, ns, list(x, y, z)) 49 | } 50 | } 51 | \seealso{ 52 | \code{\link{mongo.insert}},\cr \code{\link{mongo.update}},\cr 53 | \code{\link{mongo.find}},\cr \code{\link{mongo.find.one}},\cr 54 | \code{\link{mongo.remove}},\cr \link{mongo.bson},\cr \link{mongo}. 55 | } 56 | 57 | -------------------------------------------------------------------------------- /tests/test_bson_from.R: -------------------------------------------------------------------------------- 1 | library(rmongodb) 2 | library(jsonlite) 3 | library(RUnit) 4 | 5 | # 10 tests 6 | # 29.01.2014 7 | 8 | out <- mongo.bson.from.JSON('{"name" : "Peter"}') 9 | checkEquals(class(out), "mongo.bson") 10 | checkEquals(mongo.bson.value(out, "name"), "Peter") 11 | 12 | out <- mongo.bson.from.JSON('{"name" : {"firstname":"Peter"}, "age":12, "visa":[123,321] }') 13 | checkEquals(class(out), "mongo.bson") 14 | checkEquals(mongo.bson.value(out, "name.firstname"), "Peter") 15 | checkEquals(mongo.bson.value(out, "age"), 12) 16 | checkEquals(as.vector( mongo.bson.value(out, "visa") ), c(123,321)) 17 | 18 | checkException( mongo.bson.from.JSON( "{'name': 'Peter'}", "Not a valid JSON content: {'name': 'Peter'}")) 19 | 20 | json <- '{"a":{"b":[1,{"a":3},3]}}' 21 | cat(prettify(json)) 22 | validate(json) 23 | out <- mongo.bson.from.JSON( json ) 24 | out2 <- mongo.bson.to.list(out) 25 | checkEquals(class(out), "mongo.bson") 26 | checkEquals(class(out2), "list") 27 | checkTrue( is.vector(out2$a$b) ) 28 | 29 | # check bson.from.df 30 | bson_data <- mongo.bson.from.df(cars) 31 | res <- sapply(bson_data, mongo.bson.to.Robject) 32 | checkEquals(cars, as.data.frame(t(res))) 33 | 34 | # Dmitriy Selivanov 35 | # 2014-10-02 36 | # check bson with raw data 37 | a_lst <- list(x="foo", y="bar") 38 | a_bson_raw <- mongo.bson.from.list(lapply(X = a_lst, FUN = charToRaw)) 39 | a_simplify_F <- rawToChar(mongo.bson.to.list(b = a_bson_raw, simplify = F)$y) 40 | checkEquals(a_lst$y, a_simplify_F) 41 | a_simplify_T <- rawToChar(mongo.bson.to.list(b = a_bson_raw, simplify = T)$y) 42 | checkEquals(a_lst$y, a_simplify_T) 43 | 44 | # also check arrays 45 | lb <- list(x=list(charToRaw("foo"), charToRaw("bar"))) 46 | b <- mongo.bson.from.list(lb) 47 | checkEquals(unlist(mongo.bson.to.list(b = b, simplify = T), use.names = F), unlist(lb, use.names = F)) 48 | checkEquals(unlist(mongo.bson.to.list(b = b, simplify = F), use.names = T), unlist(lb, use.names = T)) 49 | 50 | -------------------------------------------------------------------------------- /man/mongo.gridfile.writer.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{class} 3 | \name{mongo.gridfile.writer} 4 | \alias{mongo.gridfile.writer} 5 | \title{The mongo.gridfile.writer class} 6 | \description{ 7 | Objects of class "mongo.gridfile.writer" are used to buffer multiple writes 8 | to a single GridFS file. 9 | } 10 | \details{ 11 | Use \code{\link{mongo.gridfile.writer.create}} to create an object of this 12 | class,\cr \code{\link{mongo.gridfile.writer.write}} to write data to it, 13 | and\cr \code{\link{mongo.gridfile.writer.finish}} when done writing. 14 | 15 | mongo.gridfile.writer objects have "mongo.gridfile.writer" as their class 16 | and contain an externally managed pointer to the actual data used to manage 17 | operations on the GridFS. This pointer is stored in the "mongo.gridfile" 18 | attribute of the object. The object also has a "mongo.gridfs" attribute 19 | holding a pointer to the mongo.gridfs object used in creation to prevent 20 | garbage collection on the mongo.gridfs object while the 21 | mongo.gridfile.writer is still active. 22 | } 23 | \examples{ 24 | mongo <- mongo.create() 25 | if (mongo.is.connected(mongo)) { 26 | gridfs <- mongo.gridfs.create(mongo, "grid") 27 | 28 | gfw <- mongo.gridfile.writer.create(gridfs, "test.dat") 29 | 30 | # store 4 bytes 31 | mongo.gridfile.writer.write(gfw, charToRaw("test")) 32 | 33 | # store string & LF plus 0-byte terminator 34 | buf <- writeBin("Test\\n", as.raw(1)) 35 | mongo.gridfile.writer.write(gfw, buf) 36 | 37 | # store PI as a float 38 | buf <- writeBin(3.1415926, as.raw(1), size=4, endian="little") 39 | mongo.gridfile.writer.write(gfw, buf) 40 | 41 | mongo.gridfile.writer.finish(gfw) 42 | mongo.gridfs.destroy(gridfs) 43 | } 44 | } 45 | \seealso{ 46 | \link{mongo.gridfs},\cr 47 | \code{\link{mongo.gridfile.writer.create}},\cr 48 | \code{\link{mongo.gridfile.writer.write}},\cr 49 | \code{\link{mongo.gridfile.writer.finish}}. 50 | } 51 | 52 | -------------------------------------------------------------------------------- /man/mongo.index.TTLcreate.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.index.TTLcreate} 3 | \alias{mongo.index.TTLcreate} 4 | \title{Add a time to live (TTL) index to a collection} 5 | \usage{ 6 | mongo.index.TTLcreate(mongo, ns, key, expireAfterSeconds, index_name = NULL) 7 | } 8 | \arguments{ 9 | \item{mongo}{(\link{mongo}) A mongo connection object.} 10 | 11 | \item{ns}{(string) The namespace of the collection to add a TTL index to.} 12 | 13 | \item{key}{(\link{mongo.bson}) The desired field(s) to use as the basis for expiration time. The field should be of type 'Date'. 14 | 15 | Alternately, \code{key} may be a list which will be converted to a 16 | mongo.bson object by \code{\link{mongo.bson.from.list}()}. 17 | 18 | Alternately, \code{key} may be a valid JSON character string which will be converted to a 19 | mongo.bson object by \code{\link{mongo.bson.from.JSON}()}.} 20 | 21 | \item{expireAfterSeconds}{(Numeric or Integer) The time in seconds after which records should be removed.} 22 | 23 | \item{index_name}{(string) The name of the index to be created.} 24 | } 25 | \value{ 26 | NULL if the command failed. \code{\link{mongo.get.err}()} may be 27 | MONGO_COMMAND_FAILED. 28 | 29 | (\link{mongo.bson}) The server's response if successful. 30 | } 31 | \description{ 32 | Add a time to live (TTL) index to a collection 33 | } 34 | \details{ 35 | See \url{http://docs.mongodb.org/manual/tutorial/expire-data}. 36 | } 37 | \examples{ 38 | mongo <- mongo.create() 39 | if (mongo.is.connected(mongo)) { 40 | for (i in 1:10) mongo.insert(mongo, ns = 'test.testTTL', b = list(a = i, last_updated = i)) 41 | res_bson <- mongo.index.TTLcreate (mongo, ns = 'test.testTTL', key = list(last_updated = 1), 42 | expireAfterSeconds = 3600, index_name = 'last_updated_1') 43 | print(res_bson); 44 | mongo.drop(mongo, ns = 'test.testTTL') 45 | } 46 | mongo.destroy(mongo); 47 | } 48 | \seealso{ 49 | \code{\link{mongo.index.create}} 50 | } 51 | 52 | -------------------------------------------------------------------------------- /man/mongo.bson.buffer.append.code.w.scope.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.buffer.append.code.w.scope} 3 | \alias{mongo.bson.buffer.append.code.w.scope} 4 | \title{Append a code field with a scope onto a mongo.bson.buffer} 5 | \usage{ 6 | mongo.bson.buffer.append.code.w.scope(buf, name, value) 7 | } 8 | \arguments{ 9 | \item{buf}{(\link{mongo.bson.buffer}) The buffer object to which to append.} 10 | 11 | \item{name}{(string) The name (key) of the field appended to the buffer.} 12 | 13 | \item{value}{\link{mongo.code.w.scope} The scoped javascript code.} 14 | } 15 | \value{ 16 | TRUE if successful; otherwise, FALSE if an error occured appending 17 | the data. 18 | } 19 | \description{ 20 | Append a javascript code value with a scope object onto a 21 | \link{mongo.bson.buffer}. 22 | } 23 | \details{ 24 | BSON has a special field type to indicate javascript code with a scope. This 25 | function appends such an indicator as the type of a field with its value. 26 | } 27 | \examples{ 28 | scope <- mongo.bson.from.list(list(scopevar="scopevalue")) 29 | buf <- mongo.bson.buffer.create() 30 | codeWscope <- mongo.code.w.scope.create("y = x", scope) 31 | mongo.bson.buffer.append.code.w.scope(buf, "CodeWscope1", 32 | codeWscope) 33 | 34 | # mongo.bson.buffer.append() will give the same result 35 | # as it can detect the mongo.code.w.scope object 36 | mongo.bson.buffer.append(buf, "CodeWscope2", codeWscope) 37 | 38 | b <- mongo.bson.from.buffer(buf) 39 | 40 | # The above produces a BSON object of the form: 41 | # { "CodeWscope1" : (CODEWSCOPE) "y = x" 42 | # (SCOPE) { "scopevar" : "scopevalue" }, 43 | # "CodeWscope2" : (CODEWSCOPE) "y = x" 44 | # (SCOPE) { "scopevar" : "scopevalue" } } 45 | } 46 | \seealso{ 47 | \link{mongo.code.w.scope},\cr 48 | \code{\link{mongo.code.w.scope.create}},\cr 49 | \code{\link{mongo.bson.buffer.append}},\cr 50 | \code{\link{mongo.bson.from.list}},\cr \link{mongo.bson.buffer},\cr 51 | \link{mongo.bson}. 52 | } 53 | 54 | -------------------------------------------------------------------------------- /man/mongo.bson.iterator.create.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.iterator.create} 3 | \alias{mongo.bson.iterator.create} 4 | \title{Create a mongo.bson.iterator object} 5 | \usage{ 6 | mongo.bson.iterator.create(b) 7 | } 8 | \arguments{ 9 | \item{b}{(\link{mongo.bson}) The mongo.bson object through which to iterate. 10 | 11 | \code{b} may also be a mongo.bson.iterator and is expected to point to a 12 | subobject or array. The iterator returned may be used to step through the 13 | subobject or array.} 14 | } 15 | \value{ 16 | (\link{mongo.bson.iterator}) An iterator initialized to 'before' the 17 | start of the given mongo.bson object. 18 | \code{\link{mongo.bson.iterator.next}()} should be used on the iterator 19 | first to step to the first field. 20 | } 21 | \description{ 22 | Create a \link{mongo.bson.iterator} object used to step through a given 23 | \link{mongo.bson} object one field at a time. 24 | } 25 | \examples{ 26 | buf <- mongo.bson.buffer.create() 27 | # Append a string 28 | mongo.bson.buffer.append(buf, "name", "Joe") 29 | # Append a date/time 30 | mongo.bson.buffer.append(buf, "created", Sys.time()) 31 | # Append a NULL 32 | mongo.bson.buffer.append(buf, "cars", NULL) 33 | b <- mongo.bson.from.buffer(buf) 34 | 35 | iter <- mongo.bson.iterator.create(b) 36 | while (mongo.bson.iterator.next(iter)) 37 | if (mongo.bson.iterator.key(iter) == "created") { 38 | print(mongo.bson.iterator.value(iter)) 39 | break 40 | } 41 | 42 | # The above is given for illustrative purposes, but may be performed 43 | # much easier (and faster) by the following: 44 | iter <- mongo.bson.find(b, "created") 45 | print(mongo.bson.iterator.value(iter)) 46 | } 47 | \seealso{ 48 | \link{mongo.bson.iterator},\cr \code{\link{mongo.bson.find}},\cr 49 | \code{\link{mongo.bson.iterator.next}},\cr 50 | \code{\link{mongo.bson.iterator.key}},\cr 51 | \code{\link{mongo.bson.iterator.type}},\cr 52 | \code{\link{mongo.bson.iterator.value}},\cr \link{mongo.bson}. 53 | } 54 | 55 | -------------------------------------------------------------------------------- /man/mongo.bson.from.list.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.from.list} 3 | \alias{mongo.bson.from.list} 4 | \title{Convert a list to a mongo.bson object} 5 | \usage{ 6 | mongo.bson.from.list(lst) 7 | } 8 | \arguments{ 9 | \item{lst}{(list) The list to convert. 10 | 11 | This \emph{must} be a list, \emph{not} a vector of atomic types; otherwise, 12 | an error is thrown; use \code{as.list()} as necessary.} 13 | } 14 | \value{ 15 | (\link{mongo.bson}) A mongo.bson object serialized from \code{lst}. 16 | } 17 | \description{ 18 | Convert a list to a \link{mongo.bson} object. 19 | } 20 | \details{ 21 | This function permits the simple and convenient creation of a mongo.bson 22 | object. This bypasses the creation of a \link{mongo.bson.buffer}, appending 23 | fields one by one, and then turning the buffer into a mongo.bson object with 24 | \code{\link{mongo.bson.from.buffer}()}. 25 | 26 | Note that this function and \code{\link{mongo.bson.to.list}()} perform inverse conversions. 27 | } 28 | \note{ 29 | Function converts unnamed R lists into bson arrays. 30 | It is very easy to construct bson object of any form using this function and list. 31 | } 32 | \examples{ 33 | lst <- list(name="John", age=32) 34 | b <- mongo.bson.from.list(lst) 35 | # the above produces a BSON object of the form: 36 | # { "name" : "John", "age" : 32.0 } 37 | 38 | # Convert a vector of an atomic type to a list and 39 | # then to a mongo.bson object 40 | v <- c(president="Jefferson", vice="Burr") 41 | b <- mongo.bson.from.list(as.list(v)) 42 | # the above produces a BSON object of the form: 43 | # { "president" : "Jefferson", "vice" : "Burr" } 44 | # Let's try to construct bson with array. 45 | # This one 46 | mongo.bson.from.list(list(fruits = list('apple', 'banana', 'orange'))) 47 | # will produce a BSON object of the form: 48 | # {"fruits" : ["apple", "banana", "orange"]} 49 | } 50 | \seealso{ 51 | \code{\link{mongo.bson.to.list}},\cr \link{mongo.bson},\cr 52 | \code{\link{mongo.bson.destroy}}. 53 | } 54 | 55 | -------------------------------------------------------------------------------- /src/api_gridfs.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2008-2011 10gen Inc. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | */ 15 | #include 16 | 17 | #include "libmongo/gridfs.h" 18 | 19 | SEXP mongo_gridfs_create(SEXP mongo_conn, SEXP db, SEXP prefix); 20 | SEXP mongo_gridfs_destroy(SEXP gfs); 21 | SEXP mongo_gridfs_store_file(SEXP gfs, SEXP filename, SEXP remotename, SEXP contenttype); 22 | SEXP mongo_gridfs_store(SEXP gfs, SEXP raw, SEXP remotename, SEXP contenttype); 23 | SEXP mongo_gridfs_remove_file(SEXP gfs, SEXP filename); 24 | SEXP mongo_gridfile_writer_create(SEXP gfs, SEXP remotename, SEXP contenttype); 25 | SEXP mongo_gridfile_writer_write(SEXP gfw, SEXP raw); 26 | SEXP mongo_gridfile_writer_finish(SEXP gfw); 27 | SEXP mongo_gridfile_destroy(SEXP gfile); 28 | SEXP mongo_gridfs_find(SEXP gfs, SEXP query); 29 | SEXP mongo_gridfile_get_descriptor(SEXP gfile); 30 | SEXP mongo_gridfile_get_filename(SEXP gfile); 31 | SEXP mongo_gridfile_get_chunk_size(SEXP gfile); 32 | SEXP mongo_gridfile_get_chunk_count(SEXP gfile); 33 | SEXP mongo_gridfile_get_length(SEXP gfile); 34 | SEXP mongo_gridfile_get_content_type(SEXP gfile); 35 | SEXP mongo_gridfile_get_upload_date(SEXP gfile); 36 | SEXP mongo_gridfile_get_md5(SEXP gfile); 37 | SEXP mongo_gridfile_get_metadata(SEXP gfile); 38 | SEXP mongo_gridfile_get_chunk(SEXP gfile, SEXP i); 39 | SEXP mongo_gridfile_get_chunks(SEXP gfile, SEXP start, SEXP count); 40 | SEXP mongo_gridfile_read(SEXP gfile, SEXP size); 41 | SEXP mongo_gridfile_seek(SEXP gfile, SEXP offset); 42 | -------------------------------------------------------------------------------- /man/mongo.gridfile.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \docType{class} 3 | \name{mongo.gridfile} 4 | \alias{mongo.gridfile} 5 | \title{The mongo.gridfile class} 6 | \description{ 7 | Objects of class "mongo.gridfile" are used to access gridfiles on a MongoDB 8 | server. They are created by \code{\link{mongo.gridfs.find}()}. 9 | } 10 | \details{ 11 | mongo.gridfile objects have "mongo.gridfile" as their class and contain an 12 | externally managed pointer to the actual data used to manage operations on 13 | the gridfile. This pointer is stored in the "mongo.gridfile" attribute of 14 | the object. The object also has a "mongo.gridfs" attribute holding a 15 | pointer to the mongo.gridfs object used in creation to prevent garbage 16 | collection on the mongo.gridfs object while the mongo.gridfile is still 17 | active. 18 | } 19 | \examples{ 20 | mongo <- mongo.create() 21 | if (mongo.is.connected(mongo)) { 22 | gridfs <- mongo.gridfs.create(mongo, "grid") 23 | mongo.gridfs.store.file(gridfs, "tests/test.R", "test.R") 24 | 25 | gf <- mongo.gridfs.find(gridfs, "test.R") 26 | if( !is.null(gf)){ 27 | gf 28 | mongo.gridfile.destroy(gf) 29 | } 30 | mongo.gridfs.destroy(gridfs) 31 | } 32 | } 33 | \seealso{ 34 | \code{\link{mongo.gridfs}},\cr \code{\link{mongo.gridfs.find}},\cr 35 | \code{\link{mongo.gridfile.get.filename}},\cr 36 | \code{\link{mongo.gridfile.get.descriptor}},\cr 37 | \code{\link{mongo.gridfile.get.filename}},\cr 38 | \code{\link{mongo.gridfile.get.length}},\cr 39 | \code{\link{mongo.gridfile.get.chunk.size}},\cr 40 | \code{\link{mongo.gridfile.get.chunk.count}},\cr 41 | \code{\link{mongo.gridfile.get.content.type}},\cr 42 | \code{\link{mongo.gridfile.get.upload.date}},\cr 43 | \code{\link{mongo.gridfile.get.md5}},\cr 44 | \code{\link{mongo.gridfile.get.metadata}},\cr 45 | \code{\link{mongo.gridfile.get.chunk}},\cr 46 | \code{\link{mongo.gridfile.get.chunks}},\cr 47 | \code{\link{mongo.gridfile.read}},\cr \code{\link{mongo.gridfile.seek}},\cr 48 | \code{\link{mongo.gridfile.pipe}}. 49 | } 50 | 51 | -------------------------------------------------------------------------------- /man/mongo.bson.buffer.start.array.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.buffer.start.array} 3 | \alias{mongo.bson.buffer.start.array} 4 | \title{Start an array within a mongo.bson.buffer} 5 | \usage{ 6 | mongo.bson.buffer.start.array(buf, name) 7 | } 8 | \arguments{ 9 | \item{buf}{(\link{mongo.bson.buffer}) The buffer object to which to append.} 10 | 11 | \item{name}{(string) The name (key) of the array to be appended to the 12 | buffer.} 13 | } 14 | \value{ 15 | TRUE if successful; otherwise, FALSE if an error occured appending 16 | the data. 17 | } 18 | \description{ 19 | Call this function to start an array within a \link{mongo.bson.buffer}.\cr 20 | \code{\link{mongo.bson.buffer.finish.object}()} must be called when finished 21 | appending the elements of the array. 22 | } 23 | \details{ 24 | (\code{mongo.bson.buffer.start.object()}, 25 | \code{mongo.bson.buffer.start.array()}) and\cr 26 | \code{mongo.bson.buffer.finsih.object()} may be called in a stackwise (LIFO) 27 | order to further nest arrays and documents. 28 | 29 | The names of the elements appended should properly be given sequentially 30 | numbered strings. 31 | 32 | Note that arrays will be automatically appended by the 'append' functions 33 | when appending vectors (containing more than one element) of atomic types. 34 | } 35 | \examples{ 36 | buf <- mongo.bson.buffer.create() 37 | mongo.bson.buffer.start.array(buf, "Fibonacci") 38 | x <- 0 39 | mongo.bson.buffer.append.int(buf, "0", x) 40 | y <- 1 41 | mongo.bson.buffer.append.int(buf, "1", y) 42 | for (i in 2:8) { 43 | z <- x + y 44 | mongo.bson.buffer.append.int(buf, as.character(i), z) 45 | x <- y 46 | y <- z 47 | } 48 | mongo.bson.buffer.finish.object(buf) 49 | b <- mongo.bson.from.buffer(buf) 50 | 51 | # the above produces a BSON object of the form: 52 | # { "Fibonacci" : [ 0, 1, 1, 2, 3, 5, 8, 13, 21 ] } 53 | } 54 | \seealso{ 55 | \link{mongo.bson},\cr \link{mongo.bson.buffer},\cr 56 | \code{\link{mongo.bson.buffer.finish.object}},\cr 57 | \code{\link{mongo.bson.buffer.start.array}},\cr 58 | \code{\link{mongo.bson.buffer.append}}. 59 | } 60 | 61 | -------------------------------------------------------------------------------- /src/symbols.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2008-2011 10gen Inc. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | */ 15 | #include "symbols.h" 16 | 17 | SEXP sym_as_POSIXct; 18 | SEXP sym_mongo; 19 | SEXP sym_host; 20 | SEXP sym_name; 21 | SEXP sym_username; 22 | SEXP sym_timeout; 23 | SEXP sym_mongo_bson; 24 | SEXP sym_mongo_bson_buffer; 25 | SEXP sym_mongo_bson_iterator; 26 | SEXP sym_mongo_oid; 27 | SEXP sym_increment; 28 | SEXP sym_scope; 29 | SEXP sym_mongo_cursor; 30 | SEXP sym_options; 31 | SEXP sym_subtype; 32 | SEXP sym_length; 33 | SEXP sym_mongo_gridfs; 34 | SEXP sym_mongo_gridfile; 35 | SEXP sym_mongo_gridfile_writer; 36 | 37 | 38 | void install_mongo_symbols() { 39 | sym_as_POSIXct = install("as.POSIXct"); 40 | sym_mongo = install("mongo"); 41 | sym_host = install("host"); 42 | sym_name = install("name"); 43 | sym_username = install("username"); 44 | sym_timeout = install("timeout"); 45 | sym_mongo_bson = install("mongo.bson"); 46 | sym_mongo_bson_buffer = install("mongo.bson.buffer"); 47 | sym_mongo_bson_iterator = install("mongo.bson.iterator"); 48 | sym_mongo_oid = install("mongo.oid"); 49 | sym_increment = install("increment"); 50 | sym_scope = install("scope"); 51 | sym_mongo_cursor = install("mongo.cursor"); 52 | sym_options = install("options"); 53 | sym_subtype = install("subtype"); 54 | sym_length = install("length"); 55 | sym_mongo_gridfs = install("mongo.gridfs"); 56 | sym_mongo_gridfile = install("mongo.gridfile"); 57 | sym_mongo_gridfile_writer = install("mongo.gridfile.writer"); 58 | } 59 | -------------------------------------------------------------------------------- /src/libmongo/encoding.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2012 10gen, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef BSON_ENCODING_H_ 18 | #define BSON_ENCODING_H_ 19 | 20 | MONGO_EXTERN_C_START 21 | 22 | /** 23 | * Check that a field name is valid UTF8, does not start with a '$', 24 | * and contains no '.' characters. Set bson bit field appropriately. 25 | * Note that we don't need to check for '\0' because we're using 26 | * strlen(3), which stops at '\0'. 27 | * 28 | * @param b The bson object to which field name will be appended. 29 | * @param string The field name as char*. 30 | * @param length The length of the field name. 31 | * 32 | * @return BSON_OK if valid UTF8 and BSON_ERROR if not. All BSON strings must be 33 | * valid UTF8. This function will also check whether the string 34 | * contains '.' or starts with '$', since the validity of this depends on context. 35 | * Set the value of b->err appropriately. 36 | */ 37 | int bson_check_field_name( bson *b, const char *string, 38 | const int length ); 39 | 40 | /** 41 | * Check that a string is valid UTF8. Sets the buffer bit field appropriately. 42 | * 43 | * @param b The bson object to which string will be appended. 44 | * @param string The string to check. 45 | * @param length The length of the string. 46 | * 47 | * @return BSON_OK if valid UTF-8; otherwise, BSON_ERROR. 48 | * Sets b->err on error. 49 | */ 50 | bson_bool_t bson_check_string( bson *b, const char *string, 51 | const int length ); 52 | 53 | MONGO_EXTERN_C_END 54 | #endif 55 | -------------------------------------------------------------------------------- /man/mongo.bson.buffer.append.raw.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.0.2): do not edit by hand 2 | \name{mongo.bson.buffer.append.raw} 3 | \alias{mongo.bson.buffer.append.raw} 4 | \title{Append a raw (binary) field onto a mongo.bson.buffer} 5 | \usage{ 6 | mongo.bson.buffer.append.raw(buf, name, value, subtype = NULL) 7 | } 8 | \arguments{ 9 | \item{buf}{(\link{mongo.bson.buffer}) The buffer object to which to append.} 10 | 11 | \item{name}{(string) The name (key) of the field appended to the buffer.} 12 | 13 | \item{value}{(raw) the binary data.} 14 | 15 | \item{subtype}{(as.integer) The binary data subtype. If subtype == NULL, 16 | the "subtype" attribute of the raw is used. If this is not present, 17 | mongo.binary.binary is used. The following constants are defined: \itemize{ 18 | \item\code{\link{mongo.binary.binary}} (0L) 19 | \item\code{\link{mongo.binary.function}} (1L) 20 | \item\code{\link{mongo.binary.old}} (2L) 21 | \item\code{\link{mongo.binary.uuid}} (3L) 22 | \item\code{\link{mongo.binary.md5}} (5L) 23 | \item\code{\link{mongo.binary.user}} (128L) }} 24 | } 25 | \value{ 26 | TRUE if successful; otherwise, FALSE if an error occured appending 27 | the data. 28 | } 29 | \description{ 30 | Append raw (binary) data onto a \link{mongo.bson.buffer}. 31 | } 32 | \details{ 33 | BSON has a special field type to indicate binary data. This function appends 34 | such an indicator as the type of a field with its value. 35 | 36 | If value has a \code{dims} attribute of length > 1, any \code{names} or 37 | \code{dimnames} attribute is ignored and a nested array is appended.\cr (Use 38 | \code{\link{mongo.bson.buffer.append.object}()} if you want to preserve 39 | \code{dimnames}). 40 | } 41 | \examples{ 42 | buf <- mongo.bson.buffer.create() 43 | bin <- raw(3) 44 | for (i in 0:2) 45 | bin[i] <- as.raw(i * 3) 46 | mongo.bson.buffer.append.raw(buf, "bin1", bin) 47 | 48 | # Note that mongo.bson.buffer.append() 49 | # will detect whether the value parameter 50 | # is a raw object and append the appropriate value. 51 | 52 | mongo.bson.buffer.append(buf, "bin2", bin) # gives same result 53 | } 54 | \seealso{ 55 | \code{\link{mongo.bson.buffer.append}},\cr \link{mongo.bson},\cr 56 | \link{mongo.bson.buffer}. 57 | } 58 | 59 | --------------------------------------------------------------------------------