K
K
Khurshed Abdujalil2017-04-12 13:21:17
Yii
Khurshed Abdujalil, 2017-04-12 13:21:17

How to make grouping in mongodb on Yii2 AR?

How to make grouping in mongodb on Yii2 AR?
ps Tried Product::find()->where(['user_id' => $userID])->group('city_id')->count(); does not work

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Anton Denisenko, 2017-04-12
@kapioprok

Hello, you should just re-read https://yiiframework.com.ua/ru/doc/guide/2/db-acti...

I
Ilya Karavaev, 2017-04-12
@Quieteroks

Could you at least specify what tools you use to implement AR for mongodb.
There is no grouping in a query in mongodb. For grouping, the aggregate operation is performed.
If your module does not support switching to aggregation, then you will not do this through the model either.
Saw your abstract model that will take this into account and be able to switch from search to aggregation.

M
Maxim Timofeev, 2017-04-12
@webinar

Not special in mongoDB but there is no group() method but AR, it is for yii\mongodb\Collection
www.yiiframework.com/doc-2.0/yii-mongodb-collectio...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question