Comparing version 0.6.0 to 0.7.0
0.7.0 / 2014-05-02 | ||
================== | ||
* fixed; pass $maxDistance in $near object as described in docs #43 [vkarpov15](https://github.com/vkarpov15) | ||
* fixed; cloning buffers #42 [gjohnson](https://github.com/gjohnson) | ||
* tests; a little bit more `mongodb` agnostic #34 [refack](https://github.com/refack) | ||
0.6.0 / 2014-04-01 | ||
@@ -3,0 +10,0 @@ ================== |
@@ -906,2 +906,10 @@ 'use strict'; | ||
conds[type] = val.center; | ||
var radius = 'maxDistance' in val | ||
? val.maxDistance | ||
: null; | ||
if (null != radius) { | ||
conds.$maxDistance = radius; | ||
} | ||
} else { | ||
@@ -913,10 +921,7 @@ // GeoJSON? | ||
conds[type] = { $geometry : val.center }; | ||
} | ||
var radius = 'maxDistance' in val | ||
? val.maxDistance | ||
: null; | ||
if (null != radius) { | ||
conds.$maxDistance = radius; | ||
// MongoDB 2.6 insists on maxDistance being in $near / $nearSphere | ||
if ('maxDistance' in val) { | ||
conds[type]['$maxDistance'] = val.maxDistance; | ||
} | ||
} | ||
@@ -923,0 +928,0 @@ |
@@ -49,2 +49,5 @@ 'use strict'; | ||
return RegExpClone(obj); | ||
if ('Buffer' === obj.constructor.name) | ||
return exports.cloneBuffer(obj); | ||
} | ||
@@ -318,1 +321,13 @@ | ||
/** | ||
* Clones the contents of a buffer. | ||
* | ||
* @param {Buffer} buff | ||
* @return {Buffer} | ||
*/ | ||
exports.cloneBuffer = function (buff) { | ||
var dupe = new Buffer(buff.length); | ||
buff.copy(dupe, 0, 0, buff.length); | ||
return dupe; | ||
}; |
{ | ||
"name": "mquery", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "Expressive query building for MongoDB", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
var utils = require('../lib/utils'); | ||
var assert = require('assert'); | ||
var mongo = require('mongodb'); | ||
var mongo; | ||
try { | ||
mongo = new require('mongodb'); | ||
} catch (e) {} | ||
describe('lib/utils', function() { | ||
@@ -68,4 +72,8 @@ describe('clone', function() { | ||
it('clones mongodb.ReadPreferences', function(done) { | ||
var tags = [{dc: 'tag1'}]; | ||
it('clones mongodb.ReadPreferences', function (done) { | ||
if (!mongo) return done(); | ||
var tags = [ | ||
{dc: 'tag1'} | ||
]; | ||
var prefs = [ | ||
@@ -79,3 +87,3 @@ new mongo.ReadPreference("primary"), | ||
var prefsCloned = utils.clone(prefs); | ||
for (var i = 0; i < prefsCloned.length; i++) { | ||
@@ -98,2 +106,4 @@ assert.notEqual(prefs[i], prefsCloned[i]); | ||
it('clones mongodb.Binary', function(done){ | ||
if (!mongo) return done(); | ||
var buf = new Buffer('hi'); | ||
@@ -123,3 +133,15 @@ var binary= new mongo.Binary(buf, 2); | ||
}); | ||
it('handles buffers', function(done){ | ||
var buff = new Buffer(10); | ||
buff.fill(1); | ||
var clone = utils.clone(buff); | ||
for (var i = 0; i < buff.length; i++) { | ||
assert.equal(buff[i], clone[i]); | ||
} | ||
done(); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is too big to display
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
194230
5131
3