title: NDB - Most Efficient Way to Delete a List of Keys
body: <p>I believe I need to use <code>ndb.delete_multi</code> but I am confused as to how to make it work for a specific set of keys and whether it is the most efficient way to go.  Using Python 2.7 with Google App Engine.</p>
  
  <p>First, I am collecting the keys that I want to delete.  I don't want to delete everything, only those entries that are 1 hour or more old.  Toward that end I first collect the list of keys that meet this criteria.</p>
  
  <pre><code>cs = ChannelStore()
  delMsgKeys = []
  for x in cs.allMessages():
     current = datetime.datetime.now()
     recordTime = x.channelMessageCreated
     timeDiffSecs = (current - recordTime).total_seconds()
     timeDiff = (timeDiffSecs/60)/60
     if timeDiff &gt;=1:
        delMsgKeys.append(x.key.id())
  ndb.delete_multi(?????)
  </code></pre>
  
  <p>The definition for cs.allMessages():</p>
  
  <pre><code>def allMessages(self):
          return ChannelStore.query().fetch()
  </code></pre>
  
  <p>First, is this overall the most efficient approach?  Second, how do I use the list of keys I created with the <code>ndb.delete_multi</code> statement?  </p>
  
  <p>---Update----</p>
  
  <p>The issue with the ndb.delete_multi has to do with the keys I was passing it.  In the code I posted above the keys should have been stored as follows:</p>
  
  <pre><code>delMsgKeys.append(x.key)
  </code></pre>
  
  <p>With the above ndb.delete_multi works.  </p>