{"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.7.1","deps":[],"features":{},"cksum":"sha256:ce756c0227d4c78d1cca47a4d72103f314e1f8a112abcfb8ac511289ef07bc0c","sig":"ed25519:d924d953b114e2904cf2cf2086c225d274614bebca90f25ede5468632cb1977590561f43d7f69c9ae3bc09eb9267d30ced6414fc6ae62963747cf5c031c96206","key_fp":"SHA256:jiRoI3zNjRf/jbs3rkssGHT0JSZIte0YQJ/WV2hf5xE","yanked":false,"edition":"2026","hew":">=0.10.0, <0.12.0","registry_sig":"ed25519:4e582ffdb9faf8f0f12b9df5b94b7cd8210a28eb327024291d1325c375b1d2dca165be0bcabe38a20b59567efdabdf87a1fdfc8a7854cd9350f3d49745f8c205","registry_key_fp":"SHA256:NR2yrof9/ZWkCWyhDODRU8Yvm9Lob/0yYVTdCKzMHb8","published_at":"2026-11-19T02:50:30.754Z","dl":"https://cdn.hewpkg.com/tarballs/hew/db/mongodb/0.7.1.tar.zst"}}