New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.3 to 1.0.4

.travis.yml

27

lib/schema.js
'use strict';
var util = require('util')
, DateOnly = require('dateonly')
;
var util = require('util');
var DateOnly = require('dateonly');
module.exports = exports = function(mongoose) {
var MongooseDateOnly = function DateOnly(path, options) {
var MongooseDateOnly = function DateOnly(path, options) {
mongoose.SchemaType.call(this, path, options);

@@ -37,3 +36,4 @@ };

'$all': handleArray,
'$options': handleSingle
'$options': handleSingle,
'$exists': handleExists
};

@@ -54,8 +54,21 @@

function handleExists(val) {
if (mongoose.SchemaType.prototype.$conditionalHandlers) {
return mongoose.SchemaType.prototype.$conditionalHandlers.$exists.apply(this, arguments);
}
if (typeof val !== 'boolean') {
throw new Error('$exists parameter must be a boolean!');
}
return val;
}
function handleSingle(val) {
return this.castForQuery(val); /* jshint:ignore */
return this.castForQuery(val);
}
function handleArray(val) {
var self = this; /* jshint:ignore */
var self = this;
return val.map(function(v) {

@@ -62,0 +75,0 @@ return self.castForQuery(v);

{
"name": "mongoose-dateonly",
"version": "1.0.3",
"version": "1.0.4",
"description": "Provides mongoose support for dates only, typically to avoid timezone issues.",
"main": "index.js",
"scripts": {
"test": "npm test"
"test": "mocha"
},

@@ -30,4 +30,4 @@ "repository": {

"devDependencies": {
"mongoose": "^3.8.22"
"mocha": "^4.0.1"
}
}

@@ -0,1 +1,3 @@

[![Build Status](https://travis-ci.org/boblauer/mongoose-dateonly.svg?branch=fix-exists)](https://travis-ci.org/boblauer/mongoose-dateonly)
## About ##

@@ -2,0 +4,0 @@

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

describe('MongooseDateOnly', function() {
describe('MongooseDateOnly - mongoose version ' + mongoose.version, function() {
before(function() {

@@ -118,4 +118,2 @@ DateOnly = Mod(mongoose);

assert.ok(err);
assert.equal(err.type, 'DateOnly');
assert.equal(err.name, 'CastError');
done();

@@ -291,2 +289,28 @@ });

});
it('exists == true', function (done) {
Record.create({ d: new DateOnly('1/1/2000') }, { d: undefined }, function (err) {
assert.ifError(err);
Record.find({ d: { $exists: true } }, function (err, records) {
assert.ifError(err);
assert.ok(records);
assert.equal(records.length, 1);
assert.equal(records[0].d.valueOf(), 20000001);
done();
});
});
});
it('exists == false', function (done) {
Record.create({ d: new DateOnly('1/1/2000') }, { d: undefined }, function (err) {
assert.ifError(err);
Record.find({ d: { $exists: false } }, function (err, records) {
assert.ifError(err);
assert.ok(records);
assert.equal(records.length, 1);
assert.equal(records[0].d, undefined);
done();
});
});
});
});

@@ -293,0 +317,0 @@ });

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