Sort MongoDB subdocument result (PHP code)
- or -
Post a project like this2393
£10(approx. $13)
- Posted:
- Proposals: 3
- Remote
- #1703604
- Awarded
Description
Experience Level: Intermediate
General information for the business: Marketing
Kind of development: Customization of existing program
Description of requirements/functionality: Hi - I have a document model like this; from which I need to retrieve the emails from record matching _id, with emails ordered by timestamp in reverse order.
I'm using MongoDB / PHP as the connector. Thus:
$this->db->collection->findOne(array("_id"=>new\MongoDB\BSON\ObjectID('59af0a68dd41f9e0d72b7fa1')));
I can't be sure that the emails array is being created in the correct order (in any case, I want to control the order after retrieval).
Result will be either an iterator or an array containing all emails (the array won't ever be very large)
{
"_id" : ObjectId("59af0a68dd41f9e0d72b7fa1"),
"Subject" : "My Ticket",
"emails" : [
{
"timestamp" : "1504710888",
"token" : "aff2858d01f467e50c5b157210a2fe6ca8a94880d465ae64b3",
},
{
"timestamp" : "1504710890",
"token" : "aff2858d01f467e50c5b157210a2fe6ca8a94880d465ae64b2",
},
]
}
Specific technologies required: php, mongodb
OS requirements: Linux
Extra notes:
Kind of development: Customization of existing program
Description of requirements/functionality: Hi - I have a document model like this; from which I need to retrieve the emails from record matching _id, with emails ordered by timestamp in reverse order.
I'm using MongoDB / PHP as the connector. Thus:
$this->db->collection->findOne(array("_id"=>new\MongoDB\BSON\ObjectID('59af0a68dd41f9e0d72b7fa1')));
I can't be sure that the emails array is being created in the correct order (in any case, I want to control the order after retrieval).
Result will be either an iterator or an array containing all emails (the array won't ever be very large)
{
"_id" : ObjectId("59af0a68dd41f9e0d72b7fa1"),
"Subject" : "My Ticket",
"emails" : [
{
"timestamp" : "1504710888",
"token" : "aff2858d01f467e50c5b157210a2fe6ca8a94880d465ae64b3",
},
{
"timestamp" : "1504710890",
"token" : "aff2858d01f467e50c5b157210a2fe6ca8a94880d465ae64b2",
},
]
}
Specific technologies required: php, mongodb
OS requirements: Linux
Extra notes:
Christopher W.
100% (21)Projects Completed
17
Freelancers worked with
17
Projects awarded
55%
Last project
19 May 2020
United Kingdom
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies