@@ -47,7 +47,7 @@ export abstract class RelationalController extends CRUDController {
4747 } ) ;
4848 }
4949 }
50-
50+
5151 protected constructor ( plugin : Plugin , name : string ) {
5252 super ( plugin , name ) ;
5353 RelationalController . classMap . set ( name , this ) ;
@@ -70,7 +70,7 @@ export abstract class RelationalController extends CRUDController {
7070 index : indexKey ? request . getString ( indexKey ) : null ,
7171 } ;
7272 }
73-
73+
7474 async create ( request : KuzzleRequest ) {
7575 request . input . args . index = request . getString ( 'engineId' ) ;
7676 return super . create ( request ) ;
@@ -160,8 +160,8 @@ export abstract class RelationalController extends CRUDController {
160160 const promises : Promise < void > [ ] = [ ] ;
161161
162162 promises . push ( this . deleteNested ( request , nestedFields ) ) ;
163-
164- if ( manyToManyLinkedFields !== [ ] || oneToManyLinkedFields !== [ ] ) {
163+
164+ if ( manyToManyLinkedFields . length > 0 || oneToManyLinkedFields . length > 0 ) {
165165 const document = await this . sdk . document . get ( request . getString ( 'engineId' ) , this . collection , request . getId ( ) ) ;
166166 for ( const childrenField of manyToManyLinkedFields ) {
167167 promises . push ( this . propagateDelete ( document . _source [ childrenField ] , childrenField , true , request ) ) ;
@@ -244,7 +244,7 @@ export abstract class RelationalController extends CRUDController {
244244 for ( const container of listContainer ) {
245245 promises . push ( this . genericUnlink ( request ,
246246 { collection : this . collection , document : removedObjectId , field : childrenField , index : engineId , } ,
247- container , manyToMany ) ) ;
247+ container , manyToMany ) ) ;
248248 }
249249 await Promise . all ( promises ) ;
250250 }
@@ -258,15 +258,15 @@ export abstract class RelationalController extends CRUDController {
258258 * @param manyToMany : is it manyToMany relation (or one to many?)
259259 */
260260 async genericLink ( request : KuzzleRequest , embedded : FieldPath , container : FieldPath , manyToMany : boolean ) {
261-
261+
262262 // before alteration, we verify that a document with OneToMany relation is not already linked
263263 if ( ! manyToMany ) {
264264 const containerDocument = await this . getDocumentContent ( container ) ;
265265 if ( containerDocument [ container . field ] ) {
266266 throw global . app . errors . get ( 'device-manager' , 'relational_controller' , 'already_linked' , container . collection , container . field ) ;
267267 }
268268 }
269-
269+
270270 //First we update embedded document by adding link to container document
271271 const document = await this . getDocumentContent ( embedded ) ;
272272 if ( ! document [ embedded . field ] ) {
@@ -354,7 +354,7 @@ export abstract class RelationalController extends CRUDController {
354354 catch ( err ) {
355355 if ( err . id === 'services.storage.not_found' && ! throwError ) {
356356 return null ;
357- }
357+ }
358358 throw err ;
359359 }
360360 }
@@ -431,7 +431,7 @@ export abstract class RelationalController extends CRUDController {
431431 }
432432
433433 /**
434- *
434+ *
435435 * @param index
436436 * @param collection
437437 * @param documentId
0 commit comments