Batch inside transaction

I need to write a large numbers of key value pairs to the db.
But I have to ignore items which are already present in the db, and only write new values?

My initial thought was to open a transaction, and inside this transaction, check which
keys do not exist, and create a WriteBatch add these k,v pairs to the db
But there is no obvious way to create a WriteBatch inside a transaction.
Should I just create the k, v pairs one at at time inside the txn?
Or is there a faster way?