{
"_id" : ObjectId("5b8fb8bd1fc32d075c337d7c"),
"current" : {
"title" : "My title",
"description" : "This is my description",
},
"history" : {
"1517493599" : {
"from" : NumberInt(1483264800),
"from_date" : "2017-01-01 10:00:00",
"to" : NumberInt(1517493599),
"to_date" : "2018-02-01 13:59:59",
"data" : {
"title" : "This is older title",
"description" : "Some older description",
}
},
"1483264800" : {
"from" : NumberInt(1465171200),
"from_date" : "2016-06-06 00:00:00",
"to" : NumberInt(1483264800),
"to_date" : "2017-01-01 10:00:00",
"data" : {
"title" : "Oldest title",
"description" : "Oldest description",
}
}
},
"updated_at" : ISODate("2018-09-05T11:06:37.000+0000"),
"created_at" : ISODate("2018-09-05T11:06:37.000+0000")
}
在“历史记录”下,所有元素都存储在数组中,并按unix时间戳值列出(用作数组键元素)
如果我知道确切的unix时间,很容易在历史记录数组中查找数据:
$data = DbData::where('history.1517493599.data.title', '=', 'This is older title')->get();
考虑到我不知道确切的unix时间,如何在历史记录数组中找到元素?