V
V
Vyacheslav2017-10-06 11:47:33
Yii
Vyacheslav, 2017-10-06 11:47:33

Limit and Offset for MongoDB subdocuments in yii2?

Hey!
the question is. there is data in mongo like this:

[
  '_id' => '234kdjo480dsfjk',
  'id' => 1,
  'messages' => [
    1 => 'Один',
    2 => 'Два',
    3 => 'Три',
    4 => 'Четыре',
    5 => 'Пять',
  ]
]

Is there a way to make a slice for messages (aka limit) when fetching data from mongo through yii2?
in native it is done something like this .find({id : 1}, {messages:{$slice:[0, 3]}}) Available methods
in the docks did not bring the expected result any ways?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question