@@ -31,7 +31,7 @@ Manager controls the initialization of collections, keeping record of relations
3131use Phalcon\Incubator\MongoDB\Mvc\Collection\Manager;
3232
3333$di->set(
34- 'collectionManager ',
34+ 'collectionsManager ',
3535 function () {
3636 return new Manager();
3737 }
@@ -72,68 +72,60 @@ $robots = RobotsCollection::find();
7272echo "There are ", count($robots), "\n";
7373
7474// How many mechanical robots are there?
75- $robots = RobotsCollection::find(
76- [
77- [
78- "type" => "mechanical",
79- ],
80- ]
81- );
75+ $robots = RobotsCollection::find([
76+ [
77+ "type" => "mechanical",
78+ ],
79+ ]);
8280
8381echo "There are ", count(robots), "\n";
8482
8583// Get and print virtual robots ordered by name
86- $robots = RobotsCollection::findFirst(
87- [
88- [
89- "type" => "virtual"
90- ],
91- "order" => [
92- "name" => 1,
93- ],
94- ]
95- );
84+ $robots = RobotsCollection::findFirst([
85+ [
86+ "type" => "virtual",
87+ ],
88+ "order" => [
89+ "name" => 1,
90+ ],
91+ ]);
9692
9793foreach ($robots as $robot) {
98- echo $robot->name, "\n";
94+ echo $robot->name, "\n";
9995}
10096
10197// Get first 100 virtual robots ordered by name
102- $robots = RobotsCollection::find(
103- [
104- [
105- "type" => "virtual",
106- ],
107- "order" => [
108- "name" => 1,
109- ],
110- "limit" => 100,
111- ]
112- );
98+ $robots = RobotsCollection::find([
99+ [
100+ "type" => "virtual",
101+ ],
102+ "order" => [
103+ "name" => 1,
104+ ],
105+ "limit" => 100,
106+ ]);
113107
114108foreach (RobotsCollection as $robot) {
115- echo $robot->name, "\n";
109+ echo $robot->name, "\n";
116110}
117111
118- $robot = RobotsCollection::findFirst(
119- [
120- [
121- "_id" => new ObjectId("45cbc4a0e4123f6920000002"),
122- ],
123- ]
124- );
112+ $robot = RobotsCollection::findFirst([
113+ [
114+ "_id" => new ObjectId("45cbc4a0e4123f6920000002"),
115+ ],
116+ ]);
125117
126118// Find robot by using \MongoDB\BSON\ObjectId object
127119$robot = RobotsCollection::findById(
128- new ObjectId("545eb081631d16153a293a66")
120+ new ObjectId("545eb081631d16153a293a66")
129121);
130122
131123// Find robot by using id as sting
132124$robot = RobotsCollection::findById("45cbc4a0e4123f6920000002");
133125
134126// Validate input
135127if ($robot = RobotsCollection::findById($_POST["id"])) {
136- // ...
128+ // ...
137129}
138130```
139131
0 commit comments