gernericised addToDatabase