{"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.0","deps":[],"features":{},"cksum":"sha256:15b418e7f1225fe68e5e6aefa8eb4565c0d3b6aa20a108a0a482c466f5c7b36c","sig":"ed25519:4e21ab0aef2f003564e2f5b8fdf0ac2d9ed79ef43043cd3376d527518831cb68a5c50659f106f269f3dc1c3cdfdf9971ae999d1896ab5f2bc205a0352f2f6908","key_fp":"SHA256:bkFv7568keKWVEybPdkv3PglP/WcccdGO8I/l+R9crc","yanked":false,"edition":"2026","hew":">=0.6.2, <0.7.0","registry_sig":"ed25519:3ecad4cd5aafb6d825c28ceb1f0e55919698b2e4ac4b873a675bf2aa272da745f4cb91850b534bb9db99dfdc1275450a0a1c2cdaae7728ebc86d12354d871309","registry_key_fp":"SHA256:NR2yrof9/ZWkCWyhDODRU8Yvm9Lob/0yYVTdCKzMHb8","published_at":"2026-10-21T01:45:41.671Z","dl":"https://cdn.hewpkg.com/tarballs/hew/db/mongodb/0.4.0.tar.zst"}}