How to create a new vim command in lua?

I am writing a pure lua init, so I need to convert the command:

command! BufOnly silent! call Preserve("exec '%bd|e#|bd#'")

By the way, the explanation about the above command is here: