Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need Help How do I perform a query with the library where I need to select the last records recorded and grouped by an element. #7

Open
denisVitonis opened this issue Nov 8, 2018 · 0 comments

Comments

@denisVitonis
Copy link

How do I perform a query with the library where I need to select the last records recorded and grouped by an element.
the colection name is ExampleCol and the elements _id, Hexample, Hdate

In MYSQL i do this ( SELECT * FROM TABLE WHERE CONDS GROUP BY COLUMN NAME)
In MONGO DB I had a success using this code.

db.ExampleCol.aggregate(
[
{ $sort: { HDate: -1, Hexample: -1 } },
{
$group:
{
_id: "$_Hexample",
"_Hexample": {"$last":"$_Hexample"},
lastHDate: { $last: "$HDate" }
}
}
]
)

How to Mount a query using ur library?
I tried....
$this->mongo_db->aggregate(); -not success;
$this->mongo_db->command(); -not success;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant