0
看來,當我使用addSomething函數來創建一個額外的關聯時,Sequelize會更新每個現有關聯,標記關聯的id字段爲NULL,然後用相關的id重新更新每個關聯的ID。爲什麼在這個世界上他們會這樣做,更重要的是,我怎麼能阻止它呢?Sequelize似乎正在更新添加的每個關聯記錄?
number.addCall(call).success(function(call){
console.log("addCall");
});
和控制檯輸出:
Executing: UPDATE "Calls" SET "from"='+16159572942',"to"='+16159002621',"callsid"='CAe843623d58ae3453910ce0a8e6ae065b',"direction"='inbound',"callstatus"='completed',"fromcity"='NASHVILLE',"fromstate"='TN',"fromzip"='37115',"fromcountry"='US',"callduration"='6',"id"=24,"createdAt"='2013-04-24 18:12:44.695000',"updatedAt"='2013-04-30 19:19:38.392000',"deletedAt"=NULL,"PhonenumberId"=NULL WHERE "id"=24 RETURNING *
Executing: UPDATE "Calls" SET "from"='+16159572942',"to"='+16159002621',"callsid"='CA8045f80aee98e334d57deb3a31140f7f',"direction"='inbound',"callstatus"='completed',"fromcity"='NASHVILLE',"fromstate"='TN',"fromzip"='37115',"fromcountry"='US',"callduration"='5',"id"=25,"createdAt"='2013-04-25 17:35:46.919000',"updatedAt"='2013-04-30 19:19:38.393000',"deletedAt"=NULL,"PhonenumberId"=NULL WHERE "id"=25 RETURNING *
Executing: UPDATE "Calls" SET "from"='+16159572942',"to"='+16159002621',"callsid"='CAd0c476c2f790944cd4962651a86ee299',"direction"='inbound',"callstatus"='completed',"fromcity"='NASHVILLE',"fromstate"='TN',"fromzip"='37115',"fromcountry"='US',"callduration"='6',"id"=26,"createdAt"='2013-04-30 18:42:01.838000',"updatedAt"='2013-04-30 19:19:38.393000',"deletedAt"=NULL,"PhonenumberId"=NULL WHERE "id"=26 RETURNING *
Executing: UPDATE "Calls" SET "from"='+16159572942',"to"='+16159002621',"callsid"='CAe843623d58ae3453910ce0a8e6ae065b',"direction"='inbound',"callstatus"='completed',"fromcity"='NASHVILLE',"fromstate"='TN',"fromzip"='37115',"fromcountry"='US',"callduration"='6',"id"=24,"createdAt"='2013-04-24 18:12:44.695000',"updatedAt"='2013-04-30 19:19:38.394000',"deletedAt"=NULL,"PhonenumberId"=1 WHERE "id"=24 RETURNING *
Executing: UPDATE "Calls" SET "from"='+16159572942',"to"='+16159002621',"callsid"='CA8045f80aee98e334d57deb3a31140f7f',"direction"='inbound',"callstatus"='completed',"fromcity"='NASHVILLE',"fromstate"='TN',"fromzip"='37115',"fromcountry"='US',"callduration"='5',"id"=25,"createdAt"='2013-04-25 17:35:46.919000',"updatedAt"='2013-04-30 19:19:38.395000',"deletedAt"=NULL,"PhonenumberId"=1 WHERE "id"=25 RETURNING *
Executing: UPDATE "Calls" SET "from"='+16159572942',"to"='+16159002621',"callsid"='CAd0c476c2f790944cd4962651a86ee299',"direction"='inbound',"callstatus"='completed',"fromcity"='NASHVILLE',"fromstate"='TN',"fromzip"='37115',"fromcountry"='US',"callduration"='6',"id"=26,"createdAt"='2013-04-30 18:42:01.838000',"updatedAt"='2013-04-30 19:19:38.395000',"deletedAt"=NULL,"PhonenumberId"=1 WHERE "id"=26 RETURNING *
Executing: UPDATE "Calls" SET "from"='+16159572942',"to"='+16159002621',"callsid"='CAca700726a04726c976baeec0b3b11714',"direction"='inbound',"callstatus"='ringing',"fromcity"='NASHVILLE',"fromstate"='TN',"fromzip"='37115',"fromcountry"='US',"callduration"=NULL,"id"=27,"createdAt"='2013-04-30 19:19:38.328000',"updatedAt"='2013-04-30 19:19:38.396000',"deletedAt"=NULL,"PhonenumberId"=1 WHERE "id"=27 RETURNING *
addCall
它所需要做的就是更新一個記錄,一個變量「稱之爲」代表。一旦存在數以千計或更多的與號碼關聯的呼叫,這將最終壓碎分貝。