refactor primary key options into document.js, use in put and write-stream