Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongoose-dateonly

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-dateonly - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

2

lib/schema.js

@@ -48,2 +48,3 @@ 'use strict';

val = $conditional;
if (!val) return val;
if (val instanceof RegExp) throw new Error('Can not use RegExp with DateOnly.');

@@ -59,3 +60,2 @@ return new DateOnly(val).valueOf();

if (typeof val !== 'boolean') {

@@ -62,0 +62,0 @@ throw new Error('$exists parameter must be a boolean!');

{
"name": "mongoose-dateonly",
"version": "1.0.4",
"version": "1.0.5",
"description": "Provides mongoose support for dates only, typically to avoid timezone issues.",

@@ -30,4 +30,5 @@ "main": "index.js",

"devDependencies": {
"mocha": "^4.0.1"
"mocha": "^4.0.1",
"mongoose": "^5.2.5"
}
}

@@ -51,3 +51,3 @@ var assert = require('assert')

before(function(done) {
db = mongoose.createConnection('localhost', 'mongoose_dateonly');
db = mongoose.createConnection('mongodb://localhost:27017/mongoose_dateonly', { useNewUrlParser: true });
db.once('open', function() {

@@ -58,3 +58,2 @@ schema = new mongoose.Schema({

});
Record = db.model('MDateOnly', schema);

@@ -132,2 +131,20 @@ done();

it('save with null', function(done) {
var r = new Record({ d: null });
r.save(function(err) {
assert.ifError(err);
assert.equal(r.d, null);
done();
});
});
it('save with undefined', function(done) {
var r = new Record({ d: undefined });
r.save(function(err) {
assert.ifError(err);
assert.equal(r.d, undefined);
done();
});
});
it('update', function(done) {

@@ -148,2 +165,34 @@ var r = new Record({ d: new DateOnly('1/1/2000') });

it('update with null', function(done) {
var r = new Record({ d: new DateOnly('1/1/2000') });
r.save(function(err) {
assert.ifError(err);
assert.equal(r.d.valueOf(), 20000001);
r.update({ d: null }, function(err) {
assert.ifError(err);
Record.findById(r.id, function(err, r2) {
assert.ifError(err);
assert.equal(r2.d, null);
done();
});
});
});
});
it('update with undefined', function(done) {
var r = new Record({ d: new DateOnly('1/1/2000') });
r.save(function(err) {
assert.ifError(err);
assert.equal(r.d.valueOf(), 20000001);
r.update({ d: undefined }, function(err) {
assert.ifError(err);
Record.findById(r.id, function(err, r2) {
assert.ifError(err);
assert.equal(r2.d, undefined);
done();
});
});
});
});
describe('queries', function() {

@@ -150,0 +199,0 @@ it('findById', function(done) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc