We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6b68a97 commit b950042Copy full SHA for b950042
source/includes/read/retrieve.php
@@ -1,7 +1,7 @@
1
<?php
2
require 'vendor/autoload.php';
3
4
-$uri = "<connection string>";
+$uri = getenv('MONGODB_URI') ?: throw new RuntimeException('Set the MONGODB_URI variable to your Atlas URI that connects to the sample dataset');
5
$client = new MongoDB\Client($uri);
6
7
// start-db-coll
@@ -29,14 +29,12 @@
29
30
// Finds and prints up to 5 documents with a "number_of_employees" value of 1000
31
// start-modify
32
-$options = [
33
- 'limit' => 5,
34
-];
35
-
36
-$results = $collection->find(['number_of_employees' => 1000], $options);
+$results = $collection->find(
+ ['number_of_employees' => 1000],
+ ['limit' => 5]
+);
37
38
foreach ($results as $doc) {
39
echo json_encode($doc) . "\n";
40
}
41
-// end-modify
42
-?>
+// end-modify
0 commit comments