开发者

CouchDB/Cradle How do I reverse the default sorting?

so I'm using couchDB/Cradle/and Node JS to build a simple blogging system. I want to sort the posts by date, so I used emit(docs.created_at,docs) to do so using CouchDB's default s开发者_运维知识库orting system. This works, but it places the most recent posts at the bottom instead of the top. How do i reverse this? I've looked all over, and i know you can do "descending=true", but where would I insert this statement in Cradle? In addition, the date is stored as a number format like 04-05-2011-3432:#324, how would I convert that to output the date as April 5th,2011 on the HTML page.

Thanks, I know this is probably rediculously easy, I'm just starting out and am a total couchDB/NodeJS Noob. <.<


where would I insert this statement in Cradle?

Try to pass descending=true as a view parameter, for example:

db.view('characters/all', {descending: true}, function (err, res) {
    res.forEach(function (row) {
        sys.puts(row.name + " is on the " +
                 row.force + " side of the force.");
    });
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜