0
我遇到問題sequelise.js
的max
查詢功能在返回的「成功」對象爲null
,儘管記錄的查詢如預期的那樣(並且針對的數據庫是針對的) 。使用sequelise.js返回空對象的最大查詢
不用再做了,這裏是codez;
LunaEventDomain
.max("date", {where : { "luna_event_location_id": lunaLocationId }})
.success(function(max) {
console.log("Max object, %s", max);
console.log("Max object is date? [%s]", typeof max == Date);
var result;
if (max == null) {
result = false;
} else {
result = checkHasRecordsAfter(daysInAdvance, max);
}
return result;
})
.error(function(error) {
console.log("Encountered an error from max query, [%s]", error);
});
片段1:最大的查詢代碼。
日誌備註;
Executing (default): SELECT max(`date`) as `max` FROM `luna_event` WHERE `luna_event`.`luna_event_location_id`='1';
Max object, null
Max object is date? [false]
片段2:生成的日誌。
LunaEventDomain
表有(MySQL)模式;
id int(11)
event_type enum('LOW_WATER', 'HIGH_WATER', 'MOONRISE', 'MOONSET')
date datetime
height decimal(10,3)
luna_event_location_id int(11)
當我對目標數據庫執行記錄的查詢時,我檢索到合適的響應。我究竟做錯了什麼?我希望將最大結果作爲success(function(max) { ... })
回調的一部分發送。
看起來像這是我不理解sequelisejs#sync whuch清除服務器重新啓動之間的數據庫。最大查詢在第二次請求後按預期返回! – OceanLife 2014-10-06 12:26:38