Add the C, CPP, JavaRS, KotlinC, KotlinSync, PHP, Ruby Getting Started Code - #3
Add the C, CPP, JavaRS, KotlinC, KotlinSync, PHP, Ruby Getting Started Code#3tmcneil-mdb wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds six MongoDB getting-started samples across C, C++, Java Reactive Streams, Kotlin, and PHP. Ruby is advertised but not implemented.
Changes:
- Adds sample applications that seed and query products.
- Adds build manifests, setup guides, and ignore rules.
- Expands the root client-library index.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
README.md |
Adds client-library links. |
c/hello-world/README.md |
Documents C setup and usage. |
c/hello-world/hello-world.c |
Implements the C sample. |
c/hello-world/CMakeLists.txt |
Configures the C build. |
c/hello-world/.gitignore |
Ignores C build output. |
cpp/hello-world/README.md |
Documents C++ setup and usage. |
cpp/hello-world/main.cpp |
Implements the C++ sample. |
cpp/hello-world/CMakeLists.txt |
Configures the C++ build. |
cpp/hello-world/.gitignore |
Ignores C++ build output. |
java-rs/hello-world/README.md |
Documents reactive Java usage. |
java-rs/hello-world/src/main/java/HelloWorld.java |
Implements the reactive Java sample. |
java-rs/hello-world/pom.xml |
Configures Java dependencies and execution. |
java-rs/hello-world/.gitignore |
Ignores Maven output. |
kotlin-coroutine/hello-world/README.md |
Documents coroutine sample usage. |
kotlin-coroutine/hello-world/src/main/kotlin/HelloWorld.kt |
Implements the coroutine sample. |
kotlin-coroutine/hello-world/pom.xml |
Configures coroutine dependencies and build. |
kotlin-coroutine/hello-world/.gitignore |
Ignores Maven output. |
kotlin-sync/hello-world/README.md |
Documents Kotlin Sync usage. |
kotlin-sync/hello-world/src/main/kotlin/HelloWorld.kt |
Implements the Kotlin Sync sample. |
kotlin-sync/hello-world/pom.xml |
Configures Kotlin Sync dependencies and build. |
kotlin-sync/hello-world/.gitignore |
Ignores Maven output. |
php/hello-world/README.md |
Documents PHP setup and troubleshooting. |
php/hello-world/src/HelloWorld.php |
Implements the PHP sample. |
php/hello-world/composer.json |
Declares PHP dependencies. |
php/hello-world/.gitignore |
Ignores PHP-generated files. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| #include <charconv> | ||
| #include <cstdlib> | ||
| #include <iostream> | ||
| #include <string> |
mongoKart
left a comment
There was a problem hiding this comment.
Claude feedback! Also kicked off a Copilot review.
| ); | ||
|
|
||
| public static void main(String[] args) { | ||
| String uri = System.getenv("MONGODB_URI"); |
There was a problem hiding this comment.
System.getenv("MONGODB_URI") is passed straight to MongoClients.create(uri) with no null check; if the user skips the export MONGODB_URI step (the exact failure the README tells them to check for), the app dies with a raw NPE/IllegalArgumentException stack trace instead of the friendly message the C, C++, and PHP versions print.
| Mono.from(products.deleteMany(new Document())).block(); | ||
| Mono.from(products.insertMany(SAMPLE_PRODUCTS)).block(); | ||
|
|
||
| Document product = Mono.from(products.find(eq("name", "Wireless Mouse")).first()).block(); |
There was a problem hiding this comment.
product.toJson() derefs the result of find(...).first() unguarded; the Kotlin siblings use product?.toJson(). If the insert is silently filtered (e.g. a stale/different get_started.products state or a name mismatch), this is an NPE rather than "no output".
| ) | ||
|
|
||
| fun main() = runBlocking { | ||
| val uri = System.getenv("MONGODB_URI") |
There was a problem hiding this comment.
same unchecked System.getenv("MONGODB_URI") passed to MongoClient.create(uri); missing-env-var case fails with an opaque exception instead of the guarded message used in the other languages.
| ) | ||
|
|
||
| fun main() { | ||
| val uri = System.getenv("MONGODB_URI") |
There was a problem hiding this comment.
same unchecked System.getenv("MONGODB_URI") passed to MongoClient.create(uri); missing-env-var case fails with an opaque exception instead of the guarded message used in the other languages.
| // Seed the collection so the app has data to query. Clearing the | ||
| // collection first keeps results consistent across repeated runs. | ||
| products.delete_many({}); | ||
| products.insert_many(sample_products()); |
There was a problem hiding this comment.
products.delete_many({}) and insert_many(...) return values are discarded and find_one failure falls through with no output at all; combined with no else branch, a failed seed prints nothing and exits EXIT_SUCCESS, so the README's "verify MONGODB_URI" advice is the only signal a user gets.
Description
Adds the remaining six Get Started sample applications — C, C++, Java Reactive
Streams, Kotlin Coroutines, Kotlin Sync, PHP, and Ruby — mirroring the existing
go/hello-world,node/hello-world,python/hello-world,dotnet/hello-world,and
java/hello-worldsamples. Each app connects to a MongoDB deployment usingthe connection string in the
MONGODB_URIenvironment variable, seeds a fewsample product documents into the
get_started.productscollection, thenqueries and prints one of them.
c/hello-world/— sample app, CMake build (mongoc2.0), README,.gitignorecpp/hello-world/— sample app, CMake build (mongocxx4.0), README,.gitignorejava-rs/hello-world/— sample app, Maven build (mongodb-driver-reactivestreamsviamongodb-driver-bom5.9.1, Project Reactor 2025.0.0, Java 21), README,.gitignorekotlin-coroutine/hello-world/— sample app, Maven build (mongodb-driver-kotlin-coroutine5.9.1, Kotlin 2.1.0), README,.gitignorekotlin-sync/hello-world/— sample app, Maven build (mongodb-driver-kotlin-sync5.9.1, Kotlin 2.1.0), README,.gitignorephp/hello-world/— sample app, Composer manifest (mongodb/mongodb2.0,ext-mongodb2.0), README,.gitignoreentries to the root README
This supersedes the following PRs, which targeted the wrong repository:
README changes
Testing
All six samples were run end to end on macOS by following the documented
setup steps in each README, connecting to an Atlas deployment and confirming
the expected product document was printed.
JIRA