Flushes the database from elements which meet specific conditions