abstract insertDocument and updateDocument method