0
nodejsを使用して、単一のクエリで1000レコードを削除して取得したいとします。どうか私を助けることができます。単一クエリで1000レコードを検索して削除するためにmongodbクエリが必要
queuetable.find({$query:{ Status : 0, CommunityId: { '$in': objconfig.queryCommunityIds[varCommunityId]},
DateReceived: { $gte: objcommon.timeFormat(date) } },
$hint:{Status:1,CommunityId:1,DateReceived:1}}, {}, { limit: 1000 },
function(err, queueRecords) {
callback(splitNotifications(function(notificationDet) {}, queueRecords, notificationCounter, browserCounter));
})
var splitNotifications = function(callback, queueRecords, notificationCounter, browserCounter) {
if(notificationCounter < queueRecords.length) {
global.queuetable.remove({ _id: queueRecords[notificationCounter]._id }, function(err, removeSuccess) {
console.log('removed record');
if (err){
objcommon.mongodberrorlog(objcommon.mongoTime(), err.stack, 'Error In queueOthers queue update');
// console.log('queuetable update failed in splitBrowsers.. :: Time :: '+objcommon.mongoTime()+' :: MatriId :: '+queueRecords[notificationCounter].MatriId);
process.exit(1);
}
});
logRecord[queueRecords[notificationCounter].MatriId] = {
"startTime" :0,
"endTime" :0,
"logInsertStartTime":0,
"logInsertEndTime":0,
"gcmStartTime" :0,
"gcmEndTime":0,
"gcmTime":0,
"totSentTime":0,
"browserCounter": 0,
"notificationType":0,
"DateSent":queueRecords[notificationCounter].DateSent
};
logRecord[queueRecords[notificationCounter].MatriId].startTime = getCurrentTime();
notificationCounter++;
callback(splitNotifications(function(notificationDet) {}, queueRecords, notificationCounter, browserCounter));
}
}
私はnodejsを使用して単一のクエリで1000件のレコードを削除し、取得したいです。どうか私を助けることができます。上記のコードでは、splitNotificationsを再帰的に呼び出しています。それは速く実行するが、ゆっくりと作業を取り除く。
実際に私が必要とするのは、単一のクエリです。効率的に1000レコードを読み込んで削除したい –