title: Iterate through LevelDB
body: <p>Can someone please educate me on this:</p>
  
  <p>Trying to use levelDb in a node.js instance, to store the <code>name</code> key and the <code>ID</code> string against it, I want to be able to check if the <code>ID</code> is already in the DB so...</p>
  
  <p>Looking at the <a href="https://github.com/Level/levelup#dbcreatereadstreamoptions" rel="nofollow noreferrer">documentation</a> I don't know what I'm doing wrong.</p>
  
  <p>I have <code>db.js</code> here:</p>
  
  <pre><code>var level = require('level');  
  var path = require('path');
  
  var dbPath = process.env.DB_PATH || path.join(__dirname, 'mydb');  
  var db = level(dbPath);
  
  module.exports = db;
  </code></pre>
  
  <p>And I want to be able to query the db, so my rudimentary try in <code>app.js</code> here:</p>
  
  <pre><code>var db = require('./db', {
    valueEncoding: 'json'
  })
  
  db.put('name', 'ID001')
  db.put('name', 'ID002')
  db.put('name', 'ID003')
  db.put('name', 'ID004')
  db.put('name', 'ID005')
  db.put('name', 'ID006')
  db.put('name', 'ID007')
  
  db.createReadStream()
    .on('data', function (entry) {
      console.log(entry.value);
    })
  </code></pre>
  
  <p>I thought that I was only getting the last value in the db but after running it repeatedly I got output like this:</p>
  
  <pre><code>spences10:~/workspace/level-db $ node app.js
  ID006
  spences10:~/workspace/level-db $ node app.js
  ID007
  spences10:~/workspace/level-db $ node app.js
  ID007
  spences10:~/workspace/level-db $ node app.js
  ID007
  spences10:~/workspace/level-db $ node app.js
  ID005
  spences10:~/workspace/level-db $ node app.js
  ID007
  spences10:~/workspace/level-db $ node app.js
  ID007
  spences10:~/workspace/level-db $ node app.js
  ID006
  spences10:~/workspace/level-db $ node app.js
  ID005
  spences10:~/workspace/level-db $ node app.js
  ID003
  spences10:~/workspace/level-db $ node app.js
  ID007
  </code></pre>
  
  <p>I just want to be able to either iterate through or query the db to see if a value needs to be put in there.</p>
  
  <p>I have also tried using <code>.get</code> with the same sort of result</p>
  
  <pre><code>var db = require('./db', {
    valueEncoding: 'json'
  })
  
  db.put('name', 'ID001')
  db.put('name', 'ID002')
  db.put('name', 'ID003')
  db.put('name', 'ID004')
  db.put('name', 'ID005')
  db.put('name', 'ID006')
  db.put('name', 'ID007')
  
  db.get('name', function(err, value) {  
    if (err) {
      return err;
    }
    console.log('value:', value);
  });
  </code></pre>
  
  <p>Output...</p>
  
  <pre><code>spences10:~/workspace/level-db $ node app.js
  value: ID007
  spences10:~/workspace/level-db $ node app.js
  value: ID004
  spences10:~/workspace/level-db $ node app.js
  value: ID005
  spences10:~/workspace/level-db $ node app.js
  value: ID007
  spences10:~/workspace/level-db $ node app.js
  value: ID003
  spences10:~/workspace/level-db $ node app.js
  value: ID007
  </code></pre>