{"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.6.0","deps":[],"features":{},"cksum":"sha256:02552f58e5b02f444a650a250f2bf45dc0f3f97e58a19b44e2285dc49ed6e608","sig":"ed25519:f19367be4d69a78820bfa835da24f411a769367499bbfef4f629a1967cb7e5db6f9cb9993327c912ea51733934ddf08d43c1d02ec90ad8beb4d296f7ed005b07","key_fp":"SHA256:CB3Ski8183EXzxoy+uSuMpWTxvd/4AlB8CThZu0ZG74","yanked":false,"edition":"2026","hew":">=0.9.0, <0.10.0","registry_sig":"ed25519:47a2067bc995797b1473915917a59b63aa69bc4a2c99fad74687611e3455dd30bf862c7957f5f991ac9633af04be4c8634ab3eec6789000c39c536e5e9d25e02","registry_key_fp":"SHA256:NR2yrof9/ZWkCWyhDODRU8Yvm9Lob/0yYVTdCKzMHb8","published_at":"2026-10-24T11:53:55.139Z","dl":"https://cdn.hewpkg.com/tarballs/hew/db/mongodb/0.6.0.tar.zst"}}