Title: Write MongoDB Queries with R
Version: 0.1.2
Description: Translate R code into MongoDB aggregation pipelines.
URL: https://rpkgs.gitlab.io/mongopipe, https://gitlab.com/rpkgs/mongopipe
BugReports: https://gitlab.com/rpkgs/mongopipe/-/issues
License: MIT + file LICENSE
Suggests: testthat (≥ 3.0.0), mongolite (≥ 2.2.0), nycflights13
Config/testthat/edition: 3
Encoding: UTF-8
RoxygenNote: 7.3.2
Imports: magrittr, jsonlite, rlang
NeedsCompilation: no
Packaged: 2025-04-06 17:19:22 UTC; olli
Author: Oliver Haag [aut, cre]
Maintainer: Oliver Haag <oliver_haag@e.mail.de>
Repository: CRAN
Date/Publication: 2025-04-06 17:30:02 UTC

mongopipe: Write MongoDB Queries with R

Description

Translate R code into MongoDB aggregation pipelines.

Author(s)

Maintainer: Oliver Haag oliver_haag@e.mail.de

See Also

Useful links:


Create or append a mongo aggregation stage

Description

Create or append a mongo aggregation stage

Usage

add_stage(x, ...)

## Default S3 method:
add_stage(x, ...)

## S3 method for class 'mongopipe'
add_stage(x, type, ...)

Arguments

x

Object of class mongo or mongo_pipe

...

query

type

Name of the stage.

Value

Object of type mongopipe.


Conditional expression ($cond)

Description

Evaluates a boolean expression to return one of the two specified return expressions.

Usage

condition(test, yes, no)

Arguments

test

Expression which returns a boolean value.

yes

Return this if the test returns true.

no

Return this if the test returns false.

Value

Return a list for using in mongopipe.

Examples

## Not run: 
cond <- condition(test = list("$isArray"="$chart"),
                  yes = list("$size"="$chart"),
                  no = 0)
jsonlite::toJSON(cond)

## End(Not run)


Pipeline Stages

Description

These functions translate R code to json readable by Mongodb.

Usage

match(x, ...)

## S3 method for class 'mongopipe'
match(x, ...)

field(x, ...)

## S3 method for class 'mongopipe'
field(x, ...)

lookup(x, ...)

## S3 method for class 'mongopipe'
lookup(x, from, local_field = from, foreign_field = "_id", as = from, ...)

unwind(x, ...)

## S3 method for class 'mongopipe'
unwind(x, field, ...)

limit(x, ...)

## S3 method for class 'mongopipe'
limit(x, limit, ...)

project(x, ...)

## S3 method for class 'mongopipe'
project(x, ...)

Arguments

x

Object of class mongopipe

...

list object

from

Collection to join

local_field

Field from the input documents

foreign_field

Field from the documents of the "from" collection

as

Name of output array field (Default: from)

field

Field to unwind.

limit

Integer to limit the number of documents.

Value

Object of type mongopipe.


Mongopipe

Description

Mongopipe

Usage

mongopipe()

Value

Object of type mongopipe.


Objects exported from other packages

Description

These objects are imported from other packages. Follow the links below to see their documentation.

magrittr

%>%