Fix a bug that overwrote documents in the db when some had been deleted

Just, don't rely on the number of the documents in the db to have a
fresh document number: after a deletion, documents are not renumbered...