Millions of of the data in the database, processing may be slow, so it is simple to build a smaller structure of similar tables, test data
/* 0 */
{
"_id": ObjectId ("54fe73e36e26d21dc4391bdb"),
"Create_date": Isodate ("2014-07-26t13:57:18z"),
"Rfid_no": "010101000120140322000173"
}
/* 1 */
{
"_id": ObjectId ("54FE74076E26D21DC4391BDC"),
"Create_date": Isodate ("2014-07-24t11:57:18z"),
"Rfid_no": "010101000120140322000173"
}
/* 2 */
{
"_id": ObjectId ("54FE74136E26D21DC4391BDD"),
"Create_date": Isodate ("2014-07-27t09:27:18z "),
" Rfid_no ":" 010101000120140322000173 "
}
/* 3
*
/{" _id ": ObjectId (" 54fe742a6e26d21dc4391bde "),
" Create_date ": Isodate (" 2014-07-26t13:57:18z "),
" Rfid_no ":" 010101000120140322000883 "
}
It is important to note that the join statement for the time type is:
Db.test.save ({rfid_no: ' 1 ', create_date:new DATE (' 6/26/2014 13:57:18 ')});
Writing a map
function Map () {
//Remove the same time record as RFID in the log record
emit (this
. Rfid_no, this
. Create_date
);
}
Write reduce
function Reduce (key, values) {
//combine the same RFID payback time into a record of
var ret = {rfid:key, times:[{}]};
for (var i = 0;i < values.length;i++) {
ret.times[i] = values[i];
}
return ret;
}
Configure in & Out
To run and produce the result: