{"id":13423400,"url":"https://github.com/jeroen/mongolite","last_synced_at":"2025-04-05T06:10:33.036Z","repository":{"id":21049081,"uuid":"24347934","full_name":"jeroen/mongolite","owner":"jeroen","description":"Fast and Simple MongoDB Client for R","archived":false,"fork":false,"pushed_at":"2024-04-24T13:47:42.000Z","size":7569,"stargazers_count":284,"open_issues_count":77,"forks_count":64,"subscribers_count":18,"default_branch":"master","last_synced_at":"2024-06-11T16:12:18.425Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://jeroen.github.io/mongolite/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jeroen.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-09-22T22:27:57.000Z","updated_at":"2024-06-19T00:37:22.984Z","dependencies_parsed_at":"2024-06-19T00:37:17.536Z","dependency_job_id":"3788e050-697a-4b6f-aeb5-0436dc2d619b","html_url":"https://github.com/jeroen/mongolite","commit_stats":{"total_commits":731,"total_committers":10,"mean_commits":73.1,"dds":"0.015047879616963078","last_synced_commit":"e6990469f3b41c63808f469dcab9c3fc4df8f7c5"},"previous_names":["jeroenooms/mongolite"],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeroen%2Fmongolite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeroen%2Fmongolite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeroen%2Fmongolite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeroen%2Fmongolite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeroen","download_url":"https://codeload.github.com/jeroen/mongolite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247294541,"owners_count":20915340,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T00:00:33.702Z","updated_at":"2025-04-05T06:10:33.016Z","avatar_url":"https://github.com/jeroen.png","language":"C","funding_links":[],"categories":["C","Libraries"],"sub_categories":["R"],"readme":"# mongolite\n\n##### *Fast and Simple MongoDB Client for R*\n\n[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/mongolite)](http://cran.r-project.org/package=mongolite)\n[![CRAN RStudio mirror downloads](http://cranlogs.r-pkg.org/badges/mongolite)](http://cran.r-project.org/web/packages/mongolite/index.html)\n[![Research software impact](http://depsy.org/api/package/cran/mongolite/badge.svg)](http://depsy.org/package/r/mongolite)\n\n\u003e High-level, high-performance MongoDB client based on libmongoc and\n  jsonlite. Includes support for aggregation, indexing, map-reduce, streaming,\n  SSL encryption and SASL authentication. The vignette gives a brief overview\n  of the available methods in the package.\n\n## Documentation\n\nAbout the R package:\n\n - Book: [Mongolite User Manual](https://jeroen.github.io/mongolite/)\n - Presentation: [UseR 2015 slides](http://jeroen.github.io/mongo-slides/)\n\n## Hello World\n\n\nExample using a public test server\n\n```r\ncon \u003c- mongo(\"mtcars\", url =\n  \"mongodb+srv://readwrite:test@cluster0-84vdt.mongodb.net/test\")\n\n# Wipe collection\nif(con$count() \u003e 0) \n  con$drop()\n  \n# Insert some data\ncon$insert(mtcars)\nstopifnot(con$count() == nrow(mtcars))\n\n# Query data\nmydata \u003c- con$find()\nstopifnot(all.equal(mydata, mtcars))\ncon$drop()\n\n# Automatically disconnect when connection is removed\nrm(con)\ngc()\n```\n\nInsert/retrieve data from your local mongodb server:\n\n```r\n# Init connection to local mongod\nlibrary(mongolite)\nm \u003c- mongo(collection = \"diamonds\")\n\n# Insert test data\ndata(diamonds, package=\"ggplot2\")\nm$insert(diamonds)\n\n# Check records\nm$count()\nnrow(diamonds)\n\n# Perform a query and retrieve data\nout \u003c- m$find('{\"cut\" : \"Premium\", \"price\" : { \"$lt\" : 1000 } }')\n\n# Compare\nnrow(out)\nnrow(subset(diamonds, cut == \"Premium\" \u0026 price \u003c 1000))\n```\n\nMore advanced features include map reduce:\n\n```r\n# Cross-table\ntbl \u003c- m$mapreduce(\n  map = \"function(){emit({cut:this.cut, color:this.color}, 1)}\",\n  reduce = \"function(id, counts){return Array.sum(counts)}\"\n)\n# Same as:\ndata.frame(with(diamonds, table(cut, color)))\n```\n\nImporting and exporting json or bson data:\n\n```r\n# Stream jsonlines into a connection\ntmp \u003c- tempfile()\nm$export(file(tmp))\n\n# Stream it back in R\nlibrary(jsonlite)\nmydata \u003c- stream_in(file(tmp))\n\n# Or into mongo\nm2 \u003c- mongo(\"diamonds2\")\nm2$count()\nm2$import(file(tmp))\nm2$count()\n\n# Remove the collection\nm$drop()\nm2$drop()\n```\n\n## Installation\n\nBinary packages for __OS-X__ or __Windows__ can be installed directly from CRAN:\n\n```r\ninstall.packages(\"mongolite\")\n```\n\nInstallation from source on Linux requires `openssl` and `Cyrus SASL` (**not** `GNU sasl`). On __Debian__ or __Ubuntu__ use [libssl-dev](https://packages.debian.org/testing/libssl-dev) and [libsasl2-dev](https://packages.debian.org/testing/libsasl2-dev):\n\n```\nsudo apt-get install -y libssl-dev libsasl2-dev\n```\n\nOn __Fedora__, __CentOS or RHEL__ use [openssl-devel](https://apps.fedoraproject.org/packages/openssl-devel) and [cyrus-sasl-devel](https://apps.fedoraproject.org/packages/cyrus-sasl-devel):\n\n```\nsudo yum install openssl-devel cyrus-sasl-devel\n````\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeroen%2Fmongolite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeroen%2Fmongolite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeroen%2Fmongolite/lists"}