Skip to content

Author: admin@master

Mongoose date field – Set default to date.now + N days

In a mongoose schema such as: On the line for the “end” field the default date should set to +7 days. I can add presave hook and set it there, but wondering if theres a way to do this inline in the default field. Answer You can add 7 days converted to milliseconds to current date like this or even

Javascript selected text highlighting prob

I have a html page with text content. On selecting any text and pressing the highlight button, I can change the style of the selected text to highlight the same. To implement this feature, i have written the following method. This is working fine if you choose a text with no html tag, but when the text has an…

Sequelize Where statement with date

I am using Sequelize as my backend ORM. Now I wish to do some WHERE operations on a Date. More specifically, I want to get all data where a date is between now and 7 days ago. The problem is that the documentation does not specify which operations you can do on Datatypes.DATE Can anyone point me in the right