{"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.2.0","deps":[],"features":{},"cksum":"sha256:5165fcc67494bb34340d66487ebb6d75cb638dfd352396951db38f99096a9658","sig":"ed25519:17ff333101f5f9eb9348c984ac600b9100172cc162084fa8327943ea639c14da9162fc6209ed20bfe96e4c49094e8ea65a9945b859ce8269a08a2525c02b9c00","key_fp":"SHA256:Jirr0zhp7LzbnuixrT+JkXo6OneHocCoIctlKCUkqmw","yanked":false,"edition":"2026","hew":">=0.6.0-rc1, <0.7.0","registry_sig":"ed25519:88ec8f80129fa0bc5dc85c5c77de67f1cb79a1dd83d7a8b19ce0f0e181fb14eb0fc368ef0b4fcab7a34f5d46d2a966ebb793f91a4573b3fbace2603e196e810d","registry_key_fp":"SHA256:NR2yrof9/ZWkCWyhDODRU8Yvm9Lob/0yYVTdCKzMHb8","published_at":"2026-08-15T16:49:08.168Z","dl":"https://cdn.hewpkg.com/tarballs/hew/db/mongodb/0.2.0.tar.zst"}}