Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
mongoose-dateonly
Advanced tools
Provides mongoose support for dates only, typically to avoid timezone issues.
This is an implementation of the DateOnly library that works with Mongoose. This allows you to save dates in Mongo without having to worry about time zones shifting the date.
var mongoose = require('mongoose');
var DateOnly = require('mongoose-dateonly')(mongoose);
var PersonSchema = {
birthday: DateOnly
};
...
var p1 = new Person({ birthday: '4/7/1995' });
var p2 = new Person({ birthday: new Date('4/7/1995') });
var p3 = new Person({ birthday: new DateOnly('4/7/1995') });
In Mongo, the values above would all be stored as 19950307
. Because they're not stored as conventional Date
objects, they are not subject to time zone shifts. In other words, no matter what time zone a user is in, this date will always be 4/7/1995.
The DateOnly
data type supports all of the query conditions you would expect it to:
Person.find({ birthday: '4/7/1995' });
Person.find({ birthday: { $lt: Date.now() } });
Person.find({ birthday: { $in: [ '1/1/2000', new Date('1/1/2010'), new DateOnly()]}})
For full implementation details on the DateOnly
data type, please see the documentation on the DateOnly GitHub repo.
npm test
FAQs
Provides mongoose support for dates only, typically to avoid timezone issues.
The npm package mongoose-dateonly receives a total of 509 weekly downloads. As such, mongoose-dateonly popularity was classified as not popular.
We found that mongoose-dateonly demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.