mongoose-dateonly
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -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) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28557
407
2
8