mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-31 01:47:13 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			20 lines
		
	
	
		
			440 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
		
			440 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 'use strict';
 | |
| 
 | |
| const findModelByAssoc = ({ assoc }) => {
 | |
|   const target = assoc.collection || assoc.model;
 | |
|   return assoc.plugin === 'admin'
 | |
|     ? strapi.admin.models[target]
 | |
|     : assoc.plugin
 | |
|     ? strapi.plugins[assoc.plugin].models[target]
 | |
|     : strapi.models[target];
 | |
| };
 | |
| 
 | |
| const isPolymorphic = ({ assoc }) => {
 | |
|   return assoc.nature.toLowerCase().indexOf('morph') !== -1;
 | |
| };
 | |
| 
 | |
| module.exports = {
 | |
|   findModelByAssoc,
 | |
|   isPolymorphic,
 | |
| };
 | 
