import { JSORMBase } from "../model" ; import { JsonapiResourceIdentifier } from "../jsonapi-spec" ; export default ( model , relationNames ) => { const identifiers = { } ; relationNames . forEach ( relationName => { let relatedObjects = model . relationship ( relationName ) ; if ( relatedObjects ) { if ( ! Array . isArray ( relatedObjects ) ) { relatedObjects = [ relatedObjects ] ; } relatedObjects . forEach ( r => { if ( r . isPersisted ) { if ( ! identifiers [ relationName ] ) { identifiers [ relationName ] = [ ] ; } identifiers [ relationName ] . push ( r . resourceIdentifier ) ; } } ) ; } } ) ; return identifiers ; } ;