{"id":15154377,"url":"https://github.com/flida-dev/go-mongox","last_synced_at":"2026-01-28T18:41:55.546Z","repository":{"id":244591398,"uuid":"814101116","full_name":"entrlcom/go-mongox","owner":"entrlcom","description":"Mongo + Go = ❤️","archived":false,"fork":false,"pushed_at":"2024-07-13T09:13:43.000Z","size":37,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-02-13T14:38:34.850Z","etag":null,"topics":["go","go-generics","golang","golang-library","mongo","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/entrlcom.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":"2024-06-12T10:43:20.000Z","updated_at":"2024-07-13T09:13:46.000Z","dependencies_parsed_at":"2024-06-15T22:23:54.504Z","dependency_job_id":"8f4cdbac-5a47-484f-ade6-4812787b1495","html_url":"https://github.com/entrlcom/go-mongox","commit_stats":null,"previous_names":["entrlcom/go-mongox"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/entrlcom%2Fgo-mongox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/entrlcom%2Fgo-mongox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/entrlcom%2Fgo-mongox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/entrlcom%2Fgo-mongox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/entrlcom","download_url":"https://codeload.github.com/entrlcom/go-mongox/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247648928,"owners_count":20972942,"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":["go","go-generics","golang","golang-library","mongo","mongodb"],"created_at":"2024-09-26T17:22:14.012Z","updated_at":"2026-01-20T15:33:26.579Z","avatar_url":"https://github.com/entrlcom.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mongo X\n\n## Table of Content\n\n- [Features](#features)\n\t- [Collection Methods](#collection-methods)\n\t- [Docker](#docker)\n\t- [Query Operators](#query-operators)\n\t- [Update Operators](#update-operators)\n- [Examples](#examples)\n\t- [Collection](#collection)\n\t- [Filter](#query-operator)\n- [License](#license)\n\n## Features\n\n### Collection Methods\n\n|    | Method                       | Function                |\n|----|------------------------------|-------------------------|\n| ✔️ | `db.collection.count()`      | `collection.Count()`    |\n| ✔️ | `db.collection.delete()`     | `collection.Delete()`   |\n| ✔️ | `db.collection.find()`       | `collection.Find()`     |\n| ✔️ | `db.collection.findMany()`   | `collection.FindMany()` |\n| ✔️ | `db.collection.insert()`     | `collection.Insert()`   |\n| ✔️ | `db.collection.replaceOne()` | `collection.Replace()`  |\n\n### Docker\n\nMongo in Docker is useful for testing purposes. Please, check `*_test.go` files in the `/collection` directory for\nexamples.\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\n\t\"entrlcom.dev/mongox/docker\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\n\tmongo, err := docker.NewMongo(ctx)\n\tif err != nil {\n\t\t// TODO: Handle error.\n\t\treturn\n\t}\n\n\tdefer func() {\n\t\t// TODO: Handle error.\n\t\t_ = mongo.Shutdown(ctx) //nolint:errcheck // OK.\n\t}()\n\n\tclient := mongo.GetClient()\n\n\t// ...\n}\n\n```\n\n### Query Operators\n\n#### Array Query Operators\n\n|    | Operator     | Function            |\n|----|--------------|---------------------|\n| ❌  | `$all`       |                     |\n| ✔️ | `$elemMatch` | `query.ElemMatch()` |\n| ❌  | `$size`      |                     |\n\n#### Bitwise Query Operators\n\n|   | Operator        | Function |\n|---|-----------------|----------|\n| ❌ | `$bitsAllClear` |          |\n| ❌ | `$bitsAllSet`   |          |\n| ❌ | `$bitsAnyClear` |          |\n| ❌ | `$bitsAnySet`   |          |\n\n#### Comparison Query Operators\n\n|    | Operator | Function      |\n|----|----------|---------------|\n| ✔️ | `$eq`    | `query.Eq()`  |\n| ✔️ | `$gt`    | `query.Gt()`  |\n| ✔️ | `$gte`   | `query.Gte()` |\n| ✔️ | `$in`    | `query.In()`  |\n| ✔️ | `$lt`    | `query.Lt()`  |\n| ✔️ | `$lte`   | `query.Lte()` |\n| ✔️ | `$ne`    | `query.Ne()`  |\n| ✔️ | `$nin`   | `query.Nin()` |\n\n#### Element Query Operators\n\n|   | Operator  | Function |\n|---|-----------|----------|\n| ❌ | `$exists` |          |\n| ❌ | `$type`   |          |\n\n#### Evaluation Query Operators\n\n|   | Operator      | Function |\n|---|---------------|----------|\n| ❌ | `$expr`       |          |\n| ❌ | `$jsonSchema` |          |\n| ❌ | `$mod`        |          |\n| ❌ | `$regex`      |          |\n| ❌ | `$text`       |          |\n| ❌ | `$where`      |          |\n\n#### Geospatial Query Operators\n\n|   | Operator        | Function |\n|---|-----------------|----------|\n| ❌ | `box`           |          |\n| ❌ | `center`        |          |\n| ❌ | `centerSphere`  |          |\n| ❌ | `geoIntersects` |          |\n| ❌ | `geoWithin`     |          |\n| ❌ | `geometry`      |          |\n| ❌ | `maxDistance`   |          |\n| ❌ | `minDistance`   |          |\n| ❌ | `near`          |          |\n| ❌ | `nearSphere`    |          |\n| ❌ | `polygon`       |          |\n\n#### Logical Query Operators\n\n|    | Operator | Function      |\n|----|----------|---------------|\n| ✔️ | `$and`   | `query.And()` |\n| ✔️ | `$or`    | `query.Or()`  |\n| ✔️ | `$nor`   | `query.Nor()` |\n| ✔️ | `$not`   | `query.Not()` |\n\n### Update Operators\n\n#### Array Update Operators\n\n|   | Operator    | Function |\n|---|-------------|----------|\n| ❌ | `$addToSet` |          |\n| ❌ | `$each`     |          |\n| ❌ | `$pop`      |          |\n| ❌ | `$position` |          |\n| ❌ | `$pull`     |          |\n| ❌ | `$pullAll`  |          |\n| ❌ | `$push`     |          |\n| ❌ | `$slice`    |          |\n| ❌ | `$sort`     |          |\n\n#### Bitwise Update Operators\n\n|   | Operator | Function |\n|---|----------|----------|\n| ❌ | `$bit`   |          |\n\n#### Field Update Operators\n\n|   | Operator       | Function |\n|---|----------------|----------|\n| ❌ | `$currentDate` |          |\n| ❌ | `$inc`         |          |\n| ❌ | `$max`         |          |\n| ❌ | `$min`         |          |\n| ❌ | `$mul`         |          |\n| ❌ | `$rename`      |          |\n| ❌ | `$set`         |          |\n| ❌ | `$setOnInsert` |          |\n| ❌ | `$unset`       |          |\n\n## Examples\n\n### Collection\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"time\"\n\n\t\"entrlcom.dev/mongox/collection\"\n\t\"go.mongodb.org/mongo-driver/mongo\"\n\t\"go.mongodb.org/mongo-driver/mongo/options\"\n)\n\ntype Person struct {\n\tDataOfBirth time.Time `bson:\"data_of_birth,omitempty\"`\n\tName        string    `bson:\"name,omitempty\"`\n\tTimeCreated time.Time `bson:\"time_created,omitempty\"`\n}\n\ntype Repository struct {\n\tclient     *mongo.Client\n\tcollection *mongo.Collection\n}\n\nfunc (x Repository) Create(ctx context.Context, person Person) error {\n\treturn collection.Insert[Person](x.collection).Insert(ctx, person)\n}\n\nfunc NewRepository(client *mongo.Client) Repository {\n\treturn Repository{\n\t\tclient:     client,\n\t\tcollection: client.Database(\"example\").Collection(\"person\"),\n\t}\n}\n\nfunc main() {\n\tctx := context.Background()\n\n\tclient, err := mongo.Connect(ctx, options.Client().ApplyURI(\"mongodb://127.0.0.1:27017\"))\n\tif err != nil {\n\t\t// TODO: Handle error.\n\t\treturn\n\t}\n\n\trepository := NewRepository(client)\n\n\tif err := repository.Create(ctx, Person{\n\t\tDataOfBirth: time.Date(2020, time.May, 15, 0, 0, 0, 0, time.UTC),\n\t\tName:        \"John Doe\",\n\t\tTimeCreated: time.Now().UTC(),\n\t}); err != nil {\n\t\t// TODO: Handle error.\n\t\treturn\n\t}\n\n\t// ...\n}\n\n```\n\n### Query Operator\n\n```go\npackage main\n\nimport (\n\t\"entrlcom.dev/mongox/operator/query\"\n)\n\nfunc main() {\n\tfilter := query.And(\n\t\tquery.Or(\n\t\t\tquery.Eq().Field(\"name\").String(\"Jane\"),\n\t\t\tquery.Eq().Field(\"name\").String(\"John\"),\n\t\t),\n\t\tquery.Eq().Field(\"id\").String(\"1\"),\n\t)\n\n\t// {\n\t//   \"$and\": [\n\t//     {\n\t//       \"$or\": [\n\t//         {\n\t//           \"name\": {\n\t//             \"$eq\": \"Jane\"\n\t//           }\n\t//         },\n\t//         {\n\t//           \"name\": {\n\t//             \"$eq\": \"John\"\n\t//           }\n\t//         }\n\t//       ]\n\t//     },\n\t//     {\n\t//       \"id\": {\n\t//         \"$eq\": \"1\"\n\t//       }\n\t//     }\n\t//   ]\n\t// }\n}\n\n```\n\n## License\n\n[MIT](https://choosealicense.com/licenses/mit/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflida-dev%2Fgo-mongox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflida-dev%2Fgo-mongox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflida-dev%2Fgo-mongox/lists"}