{"id":13480749,"url":"https://github.com/zbjornson/MongoDBLink","last_synced_at":"2025-03-27T11:30:54.118Z","repository":{"id":85612735,"uuid":"48783772","full_name":"zbjornson/MongoDBLink","owner":"zbjornson","description":"MongoDB driver for Mathematica","archived":false,"fork":false,"pushed_at":"2018-12-26T22:21:01.000Z","size":11151,"stargazers_count":17,"open_issues_count":6,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-25T02:40:15.567Z","etag":null,"topics":["mathematica","mongodb","mongodb-driver"],"latest_commit_sha":null,"homepage":"http://zbjornson.github.io/MongoDBLink","language":"Mathematica","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zbjornson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2015-12-30T05:34:49.000Z","updated_at":"2023-10-01T15:20:43.000Z","dependencies_parsed_at":"2023-03-13T06:05:06.671Z","dependency_job_id":null,"html_url":"https://github.com/zbjornson/MongoDBLink","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zbjornson%2FMongoDBLink","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zbjornson%2FMongoDBLink/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zbjornson%2FMongoDBLink/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zbjornson%2FMongoDBLink/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zbjornson","download_url":"https://codeload.github.com/zbjornson/MongoDBLink/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245835937,"owners_count":20680296,"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":["mathematica","mongodb","mongodb-driver"],"created_at":"2024-07-31T17:00:44.558Z","updated_at":"2025-03-27T11:30:53.696Z","avatar_url":"https://github.com/zbjornson.png","language":"Mathematica","funding_links":[],"categories":["Libraries"],"sub_categories":["Mathematica"],"readme":"⚠️ **Note: *Mathematica* v11.3 and later has [a built-in MongoLink package](https://reference.wolfram.com/language/MongoLink/guide/MongoLinkOperations.html).** This repository will likely no longer be updated, although it should continue to work.\n\n# MongoDBLink\nMongoDB driver for Mathematica\n\nA fast client for MongoDB, built on the official MongoDB java driver.\n\n## Quick setup\n\nThis will install the package in the `$AddOnsDirectory`. You may prefer `$UserAddOnsDirectory` instead.\n\n```Mathematica\ntmp = URLSave[\"https://raw.githubusercontent.com/zbjornson/MongoDBLink/master/MongoDBLink.zip\"];\ndest = FileNameJoin[{$AddOnsDirectory, \"Applications\"}];\nExtractArchive[tmp, dest];\nDeleteFile[tmp];\nPrint[\"Installed MongoDBLink to \" \u003c\u003e dest]\n```\n\n## Usage\n\n**New** docs at http://zbjornson.github.io/MongoDBLink. These are incomplete and\nthere are some interactivity bugs. When the docs are complete I will also\ndistribute them with this package.\n\nAll symbols have usage text accessible with `?symbol`, and `Options[symbol]`. Quick tutorial:\n\n```Mathematica\n(* Load the package *)\n\u003c\u003c MongoDBLink`\n\n(* Connect to server. The server must already be running. *)\nconn = OpenConnection[];\n(* Also supported:\n    OpenConnection[\"mongodb://...\"]\n    OpenConnection[\"host\", port]\n    OpenConnection[\"host\", port, \"username\", \"password\", \"database\"]\n*)\n\n(* List databases. *)\nDatabaseNames[conn]\n\n(* Get a database *)\ndb = GetDatabase[conn, \"name\"]\n\n(* List collections *)\nCollectionNames[db]\n\n(* Get a collection *)\ncoll = GetCollection[db, \"name\"]\n\n(* Add some example data. The return value is the number of documents modified,\n   which is 0 for an insert. *)\nInsertDocument[coll, {\"a\" -\u003e 1, \"b\" -\u003e 2}]\n(* Batch inserts: *)\ndocs = {\"a\" -\u003e #, \"b\" -\u003e 2 #} \u0026/@ Range[5];\nInsertDocument[coll, docs]\n\n(* Fetch all documents *)\nFindDocuments[coll]\n\n(* Limit the fields returned *)\nFindDocuments[coll, \"Fields\" -\u003e {\"b\"}]\n\n(* Paginate results *)\nFindDocuments[coll, \"Offset\"-\u003e1, \"Limit\"-\u003e1]\n\n(* Use query operators. Refer to the MongoDB docs for info on valid operators. *)\nFindDocuments[coll, {\"a\" -\u003e {\"$gt\" -\u003e 2}}]\n\n(* Some Wolfram Query operators are transparently executed on the database server: *)\ncoll[Total, \"a\"]\ncoll[Min, \"a\"]\ncoll[Max, \"a\"]\ncoll[Mean, \"a\"]\n\ncoll[;;3]\ncoll[2;;3, {\"a\"}]\n\n(* Any operator will work, but any other than those listed above effectively\n   fetch ALL data and convert it to a Dataset for calculation. *)\n\n(* Find distinct values of a field *)\nFindDistinct[coll, \"b\"]\nFindDistinct[coll, \"b\", {\"a\" -\u003e {\"$gt\" -\u003e {2}}}]\n\n(* Count documents *)\nCountDocuments[coll]\nCountDocuments[coll, {\"b\" -\u003e 2}]\n\n(* Delete documents *)\nDeleteDocument[coll, {\"a\" -\u003e 3}]\n\n(* Update or \"upsert\" documents. Note that without $set, the entire document\n   will be replaced with the new document. *)\nUpdateDocument[coll, {\"a\" -\u003e 4}, {\"$set\" -\u003e {\"a\" -\u003e -4}}]\n\n(* When inserting documents with an _id property and making queries against _id\n   fields, by default, values are automatically converted to ObjectIds. This can\n   be disabled with the option \"ConvertIds\" -\u003e False. *)\n\n(* Create an ObjectId. Use this when you want to use an ObjectId for a field\n   with a key name other than _id. Per above, _id fields are automatically\n   converted by default. *)\noid = ObjectId[] (* random ObjectId *)\noid = ObjectId[\"5849bb55ee320f0abc87b06b\"] (* from a valid string *)\n\n(* Cleanup stuff *)\nDropCollection[coll];\nDropDatabase[db] (* or DropDatabase[conn, \"name\"] *)\nCloseConnection[conn];\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzbjornson%2FMongoDBLink","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzbjornson%2FMongoDBLink","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzbjornson%2FMongoDBLink/lists"}