Keeping key version when adding same key on the same transaction

I think I found out a way to do this, if I open the database as a managed DB, I can specify the version timestamp for each key and then my values will be added correctly.

The only issue now is that with this approach, seems like NumVersionsToKeep is ignored, since I always get all versions for that key during iteration instead of only the max number by above option.

This is the code:

options := badger.DefaultOptions("./badger_db").WithNumVersionsToKeep(2)

db, err := badger.OpenManaged(options)
if err != nil {
	log.Fatal(err)
}
defer db.Close()

batch := db.NewManagedWriteBatch()
defer batch.Cancel()

err = batch.SetEntryAt(&badger.Entry{Key: []byte("a"), Value: []byte("41")}, uint64(time.Now().UnixNano()))
if err != nil {
	log.Fatal(err)
}

err = batch.SetEntryAt(&badger.Entry{Key: []byte("a"), Value: []byte("42")}, uint64(time.Now().UnixNano()))
if err != nil {
	log.Fatal(err)
}

err = batch.Flush()
if err != nil {
	log.Fatal(err)
}