arvindr21 / diskDB

A Lightweight Disk based JSON Database with a MongoDB like API for Node
http://arvindr21.github.io/diskDB
603 stars 65 forks source link

Searching on multiple attributes, returns records if any one attribute matches rather than all attributes #22

Closed hillc5 closed 8 years ago

hillc5 commented 8 years ago

Looks like

.find({ attribute1: '...', attribute2: '...' } )

is returning any records that match either attribute1 or attribute2 and not only those records that match both. I expect to only get results that match ALL attributes in the query

hillc5 commented 8 years ago

This is the root of the issue: https://github.com/arvindr21/diskDB/blob/master/lib/util.js#L110.

hillc5 commented 8 years ago

Repro:

With collection db.users

db.users.save({ username: 'test', password: 'password' });
var user = db.users.find({ username: 'tests', password: 'password' });
// returns the saved record because the passwords match.