{"id":18663272,"url":"https://github.com/ronething/mongo-go-examples","last_synced_at":"2025-07-30T00:36:29.302Z","repository":{"id":103356767,"uuid":"281170235","full_name":"ronething/mongo-go-examples","owner":"ronething","description":null,"archived":false,"fork":false,"pushed_at":"2020-07-20T16:33:50.000Z","size":72,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-18T04:36:23.255Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/ronething.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":"2020-07-20T16:31:47.000Z","updated_at":"2021-09-06T16:02:45.000Z","dependencies_parsed_at":"2023-07-07T22:00:50.444Z","dependency_job_id":null,"html_url":"https://github.com/ronething/mongo-go-examples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ronething/mongo-go-examples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronething%2Fmongo-go-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronething%2Fmongo-go-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronething%2Fmongo-go-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronething%2Fmongo-go-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ronething","download_url":"https://codeload.github.com/ronething/mongo-go-examples/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronething%2Fmongo-go-examples/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267785895,"owners_count":24144124,"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","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11-07T08:15:52.632Z","updated_at":"2025-07-30T00:36:29.276Z","avatar_url":"https://github.com/ronething.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MongoDB mongo-go-driver and Change Streams Examples\n\n- 01/09/2020: Replaced with go.mongodb.org/mongo-driver (v1.2.0)\n- 02/25/2019: Replaced with go.mongodb.org/mongo-driver (v1.0.0-rc1)\n\nA MongoDB Change Streams implementation using [mongodb-go-driver](https://github.com/mongodb/mongo-go-driver).\n\n## mongo-go-driver Examples\nExamples can be found at [examples](examples).\n\n- Aggregate\n  - $group\n  - $redact\n  - $filter\n  - $lookup\n  - $elemMatch\n- Change Streams\n- CRUD\n- RunCommand\n- Transactions\n\n## Change Streams Demo\n\nSet up a replica set\n\n```\nmkdir -p data/db\nrm -rf data/db/*\nmongod --port 30097 --dbpath data/db --logpath data/mongod.log --fork --wiredTigerCacheSizeGB .5  --replSet replset\nmongo --quiet mongodb://localhost:30097/admin --eval 'rs.initiate()'\nmongo --quiet mongodb://localhost:30097/argos?replicaSet=replset --eval 'db.oplogs.insert({\"_id\": \"30097\", \"scores\": [100]})'\n```\n\n### Case 1: Watch All Changes\n\n```\nargos \"mongodb://localhost:30097/?replicaSet=replset\"\n```\n\n### Case 2: Watch Changes From a Database\n\n```\nargos \"mongodb://localhost:30097/argos?replicaSet=replset\"\n```\n\n### Case 3: Watch Changes From a Collection\n\n```\nargos --collection oplogs \"mongodb://localhost:30097/argos?replicaSet=replset\"\n```\n\n### Case 4: Watch Changes From a Collection With a Pipeline\n\n```\nargos --collection --pipeline '[{\"$match\": {\"operationType\": \"update\"}}]' \\\n  \"mongodb://localhost:30097/argos?replicaSet=replset\"\n```\n\n### Stream POC\nIt would be nice mongo-go-drive can do stream.  See [POC](mongox/session_test.go) for an example.\n\n```\nclient.Database(db).Collection(collection).Find(filter).Project(project).Sort(sort).Decode(\u0026docs)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fronething%2Fmongo-go-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fronething%2Fmongo-go-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fronething%2Fmongo-go-examples/lists"}