This code builds a 1:n relation from a SharePoint Custom List Item to multiple documents in a SharePoint document library by using default functionality combined with some Client Side Rendering (CSR) JavaScript code.
Find a step by step guide to implement this solution here: http://coffeetime.solutions/how-to-build-a-1n-relation-between-sharepoint-list-and-library-add-documents-to-list-item/