TW: Merged setOnInsert from mongodb project.