4 回答

TA貢獻1827條經驗 獲得超8個贊
您可以簡單地運行一個 cron 作業,該作業每 3 天執行一次 mongodb 查詢
這里是 node.js 的 cron 作業:https ://www.npmjs.com/package/node-cron
var cron = require('node-cron');
cron.schedule('0 0 */3 * *', () => {
// this function is gonna be executed every 3rd day at midnight
Model.update({ ... })
});
https://crontab.guru/#0_0_*/3_*_*
每月第 3 天的 00:00。

TA貢獻1856條經驗 獲得超5個贊
我不確定這是否是您所要求的,它是一個僅包含一個項目的數組,當我們單擊時清除數組,然后將button其設為唯一值,然后將其添加到數組中.valueinputpush
If the `value` starts with *Re:*{
Push as it is.
} else {
Push: "Re: value"
}
var myInput = document.getElementById('myInput');
var myBtn = document.getElementById('myBtn');
let subject_reply = [];
myBtn.addEventListener('click', () => {
subject_reply = [];
var textValue = myInput.value;
if (textValue.startsWith("Re:") == true) {
subject_reply.push(textValue);
} else{
subject_reply.push(`Re: ${textValue}`);
}
console.log(subject_reply);
});
<input type='text' id='myInput'>
<button id='myBtn'>Click</button>

TA貢獻1860條經驗 獲得超8個贊
我知道您想替換數組中的字符串值。為此,函數“Replace()”會有所幫助。在這個特定于您的問題中,“EmailREAdder()”將幫助您在不包含“RE:”的字符串的開頭添加“RE:”。
/* Function for replacing an item */
const Replace = (arr,oldValue, newValue) => arr.splice(arr.indexOf(oldValue), 1, newValue);
/* Setting all without "RE:" to RE*/
const EmailREAdder = arr => {
arr.map(item => {
if(!item.match(/RE:/)){
Replace(arr, item, `RE: ${item}`);
}
});
}
/* code */
let users = [
"RE: Farman Ali",
"Usman",
"Fraz"
];
console.log(users);
EmailREAdder(users);
console.log(users);

TA貢獻1951條經驗 獲得超3個贊
很難回答一個措辭不佳的問題。據我了解,其中之一就是您尋求的答案:
subject_reply.push("Re: " + email.subject.replace(/^Re:\s?/, ""));
要么
subject_reply[0] = "Re: " + email.subject.replace(/^Re:\s?/, "");
添加回答
舉報