We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
This is my raw code:
$query = []; $query[] = [ '$match' => [ "updatedAt" => [ '$gte' => new \MongoDB\BSON\UTCDateTime() ] ] ]; $query[] = [ '$unwind' => '$messages' ]; $query[] = [ '$match' => [ "messages.publicMessage.time" => [ '$gte' => strtotime('-1 day') * 1000 ], ] ]; $messages = Yii::$app->mongodb->createCommand()->aggregate(Queue::collectionName(), $query);
which generates bad query with backslashed ISODate:
dev.command({"aggregate":"queues","pipeline":[{"$match":{"updatedAt":{"$gte":"ISODate(\"2018-06-28T23:23:00.000Z\")"}}},{"$unwind":"$messages"},{"$match":{"messages.publicMessage.time":{"$gte":1530176891000}}}],"allowDiskUse":false,"cursor":{}})
Other atempts:
"updatedAt" => [ '$gte' => new MongoDB\BSON\UTCDateTime(strtotime('-1 day')) ]
gives:
dev.command({"aggregate":"queues","pipeline":[{"$match":{"updatedAt":{"$gte":"MongoDB\\BSON\\UTCDateTime(1530177111)"}}},{"$unwind":"$messages"},{"$match":{"messages.publicMessage.time":{"$gte":1530177111000}}}],"allowDiskUse":false,"cursor":{}})
also bad - with class name and also backslashed
dev.command({"aggregate":"queues","pipeline":[{"$match":{"updatedAt":{"$gte":{"date":"1970-01-18 17:02:57.308000","timezone_type":1,"timezone":"+00:00"}}}},{"$unwind":"$messages"},{"$match":{"messages.publicMessage.time":{"$gte":1530177308000}}}],"allowDiskUse":false,"cursor":{}})
still bad - not compatible with mongo date or $dateToString
dev.command({"aggregate":"queues","pipeline":[{"$match":{"updatedAt":{"$gte":ISODate("2018-02-09T05:00:00Z")}}},{"$unwind":"$messages"},{"$match":{"messages.publicMessage.time":{"$gte":1530176891000}}}],"allowDiskUse":false,"cursor":{}})
The text was updated successfully, but these errors were encountered:
当使用时间作为match条件时,一般使用范围查询,并且使用UTCDatetime格式。
Sorry, something went wrong.
No branches or pull requests
What steps will reproduce the problem?
This is my raw code:
which generates bad query with backslashed ISODate:
Other atempts:
gives:
also bad - with class name and also backslashed
still bad - not compatible with mongo date or $dateToString
What's expected?
What do you get instead?
Additional info
The text was updated successfully, but these errors were encountered: