{"id":13601059,"url":"https://github.com/simagix/mongo-go-examples","last_synced_at":"2026-03-17T04:44:10.506Z","repository":{"id":57486392,"uuid":"152373728","full_name":"simagix/mongo-go-examples","owner":"simagix","description":"mongo-go-driver examples","archived":false,"fork":false,"pushed_at":"2020-09-23T15:37:04.000Z","size":82,"stargazers_count":209,"open_issues_count":0,"forks_count":36,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-21T21:51:16.703Z","etag":null,"topics":["golang","mongo-go-driver","mongodb"],"latest_commit_sha":null,"homepage":"","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/simagix.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}},"created_at":"2018-10-10T06:27:15.000Z","updated_at":"2024-09-13T04:32:22.000Z","dependencies_parsed_at":"2022-09-01T21:02:05.939Z","dependency_job_id":null,"html_url":"https://github.com/simagix/mongo-go-examples","commit_stats":null,"previous_names":["simagix/argos"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simagix%2Fmongo-go-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simagix%2Fmongo-go-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simagix%2Fmongo-go-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simagix%2Fmongo-go-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simagix","download_url":"https://codeload.github.com/simagix/mongo-go-examples/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247470322,"owners_count":20944146,"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":["golang","mongo-go-driver","mongodb"],"created_at":"2024-08-01T18:00:54.385Z","updated_at":"2026-03-17T04:44:05.470Z","avatar_url":"https://github.com/simagix.png","language":"Go","funding_links":[],"categories":["Go"],"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%2Fsimagix%2Fmongo-go-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimagix%2Fmongo-go-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimagix%2Fmongo-go-examples/lists"}