dhavalpzala / multi-hashmap

MIT License
3 stars 2 forks source link

Have the query API work without a value #2

Open praveenpuglia opened 8 years ago

praveenpuglia commented 8 years ago
var MultiHashMap = require('multi-hashmap').MultiHashMap;

var players = new MultiHashMap('id', 'firstName', 'lastName', 'sport');
players.insert(1, 'Sachin', 'Tendulkar', 'cricket');
players.insert(2, 'Pusarla', 'Sindhu', 'badminton');
players.insert(3, 'Roger', 'Federer', 'tennis');
players.insert(4, 'Saina', 'Nehwal', 'badminton');

players.find('id', 2) // --> [2, 'Pusarla', 'Sindhu', 'badminton']

In this example, if I do players.find('id') I get null returned. There would be a lot of cases, where I would not know what the value is, but I just want to get every value possible for that key.

players.find('id'); // [1,2,3,4];

If the API isn't required to support the above, then it must throw an error to the user saying it requires a value to be passed. I, personally think that I should be able to query without specifying a specific value.

If we have a go on this, I can definitely send a PR.

dhavalpzala commented 8 years ago

Yes, @praveenpuglia we have to cover all this cases.

Go ahead with your PR.