NBS Posted January 24, 2017 Report Posted January 24, 2017 Labdien, Vēlējos apjautāties kā pareizi jāveido MongoDB aggregate pieprasījums ar PHP palīdzību ? Meiģināšu šādu: http://php.net/manual/en/mongocollection.aggregate.php, bet neizdodas. Stāv Xampp ar PHP 5.6 uz Windows 7. Dataseti: { "_id": { "$oid": "58868a5737d44aec0c86ea7d" }, "serial": "0002100032", "topic": "TEMPERATURE", "payload": { "temp-ch1-0002100032": "46.50" }, "_msgid": "dbf9bde5.643f6", "timestamp": "2017-01-23T22:57:27.741Z" } { "_id": { "$oid": "58868a5737d44aec0c86ea7f" }, "serial": "0002100032", "topic": "TEMPERATURE", "payload": { "temp-ch2-0002100032": "40.19" }, "_msgid": "dbf9bde5.643f6", "timestamp": "2017-01-23T22:57:27.748Z" } { "_id": { "$oid": "58868b8137d44aec0c86eaa7" }, "serial": "0002100032", "topic": "TEMPERATURE", "payload": { "temp-ch1-0002100032": "46.50" }, "_msgid": "76b17f37.89414", "timestamp": "2017-01-23T23:02:25.745Z" } { "_id": { "$oid": "58868b8137d44aec0c86eaa9" }, "serial": "0002100032", "topic": "TEMPERATURE", "payload": { "temp-ch2-0002100032": "40.19" }, "_msgid": "76b17f37.89414", "timestamp": "2017-01-23T23:02:25.750Z" } Vēlos nosummēt "temp-ch2-0002100032". $usage = $db->Usage->aggregate(array('$serial' => array('payload' => 'temp-ch1-6F0011'))); Loģiski kļūda: Fatal error: Uncaught exception 'MongoResultException' with message 'ds029486.mlab.com:29486: Unrecognized pipeline stage name: '$serial'' in C:\xampp2\htdocs\mongodb.php:8 Stack trace: #0 C:\xampp2\htdocs\mongodb.php(8): MongoCollection->aggregate(Array) #1 {main} thrown in C:\xampp2\htdocs\mongodb.php on line 8 Aizmirsu piemirst, ka MongoDB esmu izcils iesācējs, bet pats MongoDB strādā un saslēgums strādā, `find` var pielietot un izgūt kādu rezultātu. Ceru uz izpratni. Quote
Wuu Posted January 24, 2017 Report Posted January 24, 2017 (edited) Pārliecinies, ka datubāzes versija atbilst manuālim, pēc kura vadies. Bezmaksas hostings nesteidzās un mongodb versiju neatjauno. Edited January 24, 2017 by Wuu Quote
NBS Posted January 24, 2017 Author Report Posted January 24, 2017 Ir kāds paraugs ar ko varētu padalīties ? Quote
jurchiks Posted January 24, 2017 Report Posted January 24, 2017 Kāds hostings, viņam xampp uz sava PC stāv. Quote
Wuu Posted January 24, 2017 Report Posted January 24, 2017 Kāds hostings, viņam xampp uz sava PC stāv. O rly, "ds029486.mlab.com:29486"? NBS, esi pārliecināts, ka tas ko tu vēlies izdarīt tiek atbalstīts mongd 3.2 versijā? Quote
NBS Posted January 25, 2017 Author Report Posted January 25, 2017 No mlab.com cik var noprast: mongod version: 3.2.11 (MMAPv1) Protams, vai viņi nemelo to jau es nezinu. Pieprasījumus veicu lokāli vai tas ko ietekmē nav ne jausmas. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.