mirror of
				https://github.com/strapi/strapi.git
				synced 2025-11-04 11:54:10 +00:00 
			
		
		
		
	Fix deep delete relation for oneWay and when there is no relations
This commit is contained in:
		
							parent
							
								
									ebd60f93cc
								
							
						
					
					
						commit
						d586442fbd
					
				@ -129,6 +129,10 @@ module.exports = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    await Promise.all(
 | 
					    await Promise.all(
 | 
				
			||||||
      <%= globalID %>.associations.map(async association => {
 | 
					      <%= globalID %>.associations.map(async association => {
 | 
				
			||||||
 | 
					        if (!association.via || !data._id) {
 | 
				
			||||||
 | 
					          return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const search = _.endsWith(association.nature, 'One') || association.nature === 'oneToMany' ? { [association.via]: data._id } : { [association.via]: { $in: [data._id] } };
 | 
					        const search = _.endsWith(association.nature, 'One') || association.nature === 'oneToMany' ? { [association.via]: data._id } : { [association.via]: { $in: [data._id] } };
 | 
				
			||||||
        const update = _.endsWith(association.nature, 'One') || association.nature === 'oneToMany' ? { [association.via]: null } : { $pull: { [association.via]: data._id } };
 | 
					        const update = _.endsWith(association.nature, 'One') || association.nature === 'oneToMany' ? { [association.via]: null } : { $pull: { [association.via]: data._id } };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user