{"metadata":{"name":"hew/db/mongodb","vers":"0.7.1","description":"Actor-owned MongoDB client with typed errors and JSON document queries","license":"MIT OR Apache-2.0","authors":["Hew Contributors"],"deps":[],"features":{},"keywords":["database","mongodb","nosql","document"],"repository":"https://github.com/hew-lang/ecosystem","edition":"2026","hew":">=0.10.0, <0.12.0","readme":"# hew.db.mongodb\n\n`hew.db.mongodb` is an actor-owned MongoDB client. Documents, filters, and\nupdates are JSON objects. Every operation fails with a typed `MongoError`,\nwhich a call reports as `.Err(.Failed(error))`; missing\ndocuments are represented by `DocumentLookup.Missing`, separately from\nconnection and query failures.\n\n```hew\nimport hew.db.mongodb;\n\nfn main() {\n    let db = spawn mongodb.Conn {\n        uri: \"mongodb://127.0.0.1:27017\",\n        database: \"example\",\n    };\n\n    match db.insert_one(\"users\", \"{\\\"name\\\":\\\"Alice\\\",\\\"age\\\":30}\") {\n        .Ok(id) => println(f\"inserted {id}\"),\n        .Err(.Failed(error)) => println(mongodb.error_message(error)),\n        .Err(_) => println(\"MongoDB actor stopped before replying\"),\n    }\n\n    match db.find_one(\"users\", \"{\\\"name\\\":\\\"Alice\\\"}\") {\n        .Ok(.Found(document)) => println(document),\n        .Ok(.Missing) => println(\"user not found\"),\n        .Err(.Failed(error)) => println(mongodb.error_message(error)),\n        .Err(_) => println(\"MongoDB actor stopped before replying\"),\n    }\n\n    stop(db);\n    stopped(db);\n}\n```\n\nThe checked example lives at [`examples/basic.hew`](examples/basic.hew). Run\nit from the ecosystem checkout with a MongoDB server listening locally:\n\n```sh\nhew run --pkg-path . db/mongodb/examples/basic.hew\n```\n\nConstruction performs a server ping. Add a bounded\n`serverSelectionTimeoutMS` URI option when the application needs a deadline\nshorter than the MongoDB driver's default. An unreachable server is preserved\nas `MongoError.Connect`; later calls do not disguise it as an empty result.\nThe native package accepts direct `mongodb://` seed-list URIs; DNS SRV\ndiscovery through `mongodb+srv://` is not enabled in this portable static-link\nprofile.\n\n`find_one` returns `DocumentLookup.Missing` when no document matches. `find`\nreturns an immutable `QueryResult` containing every matching document. The\nnative MongoDB cursor is a private Hew `#[resource]`: it is always closed\nbefore the actor replies, including query-row and serialization failure paths.\nThe actor closes its client in its stop hook.\n\nAll Hew-to-native string inputs cross as managed Hew strings, which carry an\nexact byte length, and all native data results return as owned Hew `bytes`\ntriples before Hew decodes their UTF-8 JSON or identifier text. Document\nvalues are therefore never truncated at embedded NUL bytes; valid JSON escapes\nare preserved, while invalid raw NUL in JSON is reported as\n`MongoError.InvalidJson` instead of changing the submitted value.\n\nNative unit tests run without a server:\n\n```sh\ncargo test -p hew-ecosystem-db-mongodb\n```\n\nThe public Hew test deliberately uses an unreachable bounded-time URI to cover\nconnection failure and post-close behavior without external services:\n\n```sh\nhew run --pkg-path . db/mongodb/tests/public_api.hew\n```\n\nWith MongoDB listening on `127.0.0.1:27017`, the service-backed suite covers\nsuccessful CRUD, missing documents, invalid JSON for every operation, exact\ncounts, query contents, and repeated cursor lifecycle behavior:\n\n```sh\nhew run --pkg-path . db/mongodb/tests/integration.hew\n```\n"},"version":{"name":"hew/db/mongodb","vers":"0.4.1","deps":[],"features":{},"cksum":"sha256:8b6f8bed6d21ea16a9ff56b2c7785d60e364fefc05cb25c91def9fc347cf8a56","sig":"ed25519:b68537d4a401e345b5c6917ac4248fdd45b2d5ed3a81bc511c5517e1daa1e92e41426e17d349d4576cd358d723775417511896499a926282fe00f867e36b380f","key_fp":"SHA256:gk8UzG1JaUDuLgtKkCWyxdIF7vtNvUrDqykgv3ZwQTo","yanked":false,"edition":"2026","hew":">=0.6.2, <0.8.0","registry_sig":"ed25519:018fda3dd827c8d8c2c04ac377e539c0a8ea17cf8048406508d2bc2b1d6b11ff2180117d9c778259eac39d1bd6f8607c2d33b2ab989149a68f2c551f50100802","registry_key_fp":"SHA256:NR2yrof9/ZWkCWyhDODRU8Yvm9Lob/0yYVTdCKzMHb8","published_at":"2026-10-22T10:01:14.383Z","dl":"https://cdn.hewpkg.com/tarballs/hew/db/mongodb/0.4.1.tar.zst"}}