CouchAppの「user-is-online」統計のサーバー時間が必要です。私はjquery.couch.jsを使用しており、タイムスタンプを取得する/ db / _design / app/timeなどのURLを使用したいと考えています。どうすればこれを実現できますか?
1834 次
1 に答える
5
show関数はそれを行うことができます:
function(doc, req) {
// _design/myapp/_show/now
// First version possibly incompatible with some spidermonkey versions.
//var now = new Date();
var now = new Date().getTime();
var output = JSON.parse(JSON.stringify(now)) + "\n";
return { code: 200
, headers: { "Content-Type": "text/plain"
}
, body:output
};
}
サーバーには、使用する可能性のあるDate
ヘッダーも含まれています。
$ curl -D- http://localhost:5984
HTTP/1.1 200 OK
Server: CouchDB/1.1.0 (Erlang OTP/R14B)
Date: Fri, 27 May 2011 00:28:31 GMT
Content-Type: text/plain;charset=utf-8
Content-Length: 40
Cache-Control: must-revalidate
{"couchdb":"Welcome","version":"1.1.0"}
于 2011-05-27T00:29:24.707 に答える