Skip to content
This repository has been archived by the owner on Jul 7, 2021. It is now read-only.

リビジョンのテーブルをカラムを指定してソートできるようにする #1

Open
ryu1kn opened this issue Feb 17, 2015 · 9 comments
Assignees

Comments

@ryu1kn
Copy link
Contributor

ryu1kn commented Feb 17, 2015

No description provided.

@ryu1kn ryu1kn self-assigned this Feb 18, 2015
@ryu1kn
Copy link
Contributor Author

ryu1kn commented Feb 19, 2015

ソートはクライアントサイドじゃなくてサーバーサイドだよね?
となると GET /api/captures api を拡張して order を受け取れるようにする必要がある。その情報を findCaptures の sort に渡す。

// TODO: return "meta" and "items"
function findCaptures(skip, limit) {
  return Q.ninvoke(db.captures, 'aggregate', [
    {$match: {checkedAs: 'IS_OK'}},
    {$group: {
      _id: '$capture',
      updatedAt: {$max: '$updatedAt'},
      updatedBy: {$last: '$updatedBy'},
      expectedRevisions: { $push: '$revision' } } },
    {$sort: {_id: -1}},
    {$skip: skip || 0},
    {$limit: limit || DEFAULT_LIMIT}
  ]);
}

@piglovesyou
Copy link
Member

yes > サーバーサイド
no > GET /api/captures
Please use a current API endpoint the page you are looking.

@ryu1kn
Copy link
Contributor Author

ryu1kn commented Feb 19, 2015

Do you mean you don't have to receive order like you do for skip or limit?

@piglovesyou
Copy link
Member

no, please use GET /api/revisions/{rid}/captures which already has an ordering functionality.

@ryu1kn
Copy link
Contributor Author

ryu1kn commented Feb 19, 2015

Ah, I see. I didn't mean to use GET /api/captures as it'll retrieve all the captures from all the revisions. Sorry that I wrote the wrong one.

@piglovesyou
Copy link
Member

Yes in that way you are right ask any time

@ryu1kn
Copy link
Contributor Author

ryu1kn commented Feb 19, 2015

Yeah, what I wanted to say is that I'm going to add a query parameter order for the request of reading captures (for a certain revision).

@piglovesyou
Copy link
Member

Yes you are right please use an existing ordering functionality of GET /api/revisions/{rid}/captures

@piglovesyou
Copy link
Member

order=id:ascending&order=revisionAt:descending で複数カラムでソートできるようにしました。

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants