2011-12-05 20 views
1

我一直在嘗試在Cradle中使用多個按鍵以獲得愉快的時間,因爲我無法在任何地方找到幫助,所以我幾乎放棄了。如何使用Node.js Cradle和多個密鑰?

我用這個查詢使用一個HTTP請求,它帶給我的結果

gps_map/_design/carros/_view/teste?startkey=[353451044986295]&endkey=[353451044986296,{}]&limit=50 

但我不知道如何使用搖籃達到相同的結果,我已經試過

var car = 353451044986295; 
db.view('carros/teste',{limit:50,startkey:[car],endkey:[car,{}]},function(err,res) 

var car = 353451044986295; 
db.view('carros/teste',{limit:50,startkey:'['+car+']',endkey:'['+car+',{}]'},function(err,res) 

,並沒有成功,也沒有結果。我如何在搖籃中使用多個鍵?

+0

什麼是你的錯誤? –

+0

沒有,它簡單的沒有發現任何結果 –

回答

1

查看您的couchdb日誌,看看實際對數據庫做了什麼請求。 正在生成的請求字符串可能不是您所期望的。 您可能還需要設置降序= true?

+0

我已經放棄了搖籃,並繼續前進。我正在使用一個純粹的http請求,它只是適合我的目的 –

+0

看着日誌確實幫了我。 http:// /_log沒有數據庫在URL中,只是根目錄+ _log –

0

這句法爲我工作:

CoffeeScript的版本:

filterRange = 
    startkey:[100] 
    endkey:[400] 

@dbClient.view 'business/customers', filterRange, (err, results, fields) => 
    if err 
     throw err 

JavaScript版本:

var filterRange, _this = this; 
filterRange = { 
    startkey: ["business_9ba1b5c72af4072b2885b10d36000fa0"], 
    endkey: ["business_9ba1b5c72af4072b2885b10d36000fa0", {}] 
}; 

this.dbClient.view('business/customers', filterRange, function(err, results, fields) { 
    if (err) throw err 
};