Browse Source

ref null check

Ivan Asmer 1 year ago
parent
commit
e368b8387e
1 changed files with 4 additions and 2 deletions
  1. 4 2
      index.js

+ 4 - 2
index.js

@@ -135,7 +135,8 @@ const mm = db => {
                         for (const ref of removedRefs){
                             try { await ref } catch (e) {console.log('SYNC RELATIONS REMOVE ERROR') }
 
-                            await ref.removeRelation(this, relation)
+                            if (ref instanceof Savable)
+                                await ref.removeRelation(this, relation)
                         }
                     }
                     if (valueAsArray){ //check for added refs
@@ -264,7 +265,8 @@ const mm = db => {
                             await ref
                         }
                         catch (e) {console.log('DELETE SYNC RELATIONS ERROR') }
-                        await ref.removeRelation(this, relation)
+                        if (ref instanceof Savable)
+                            await ref.removeRelation(this, relation)
                     }
                 }
             }