浏览代码

ref null check

Ivan Asmer 1 年之前
父节点
当前提交
e368b8387e
共有 1 个文件被更改,包括 4 次插入2 次删除
  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)
                     }
                 }
             }