Update index.js

1. For users like me who define _id of doc before it's saved for the first time. (Old code didn't create field createdAt if doc had already _id)
2. For existing doc adds createdAt field automatically when doc is saved.