Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mongoidサポートを追加しました #9

Merged
5 commits merged into from Feb 17, 2011
Merged

Mongoidサポートを追加しました #9

5 commits merged into from Feb 17, 2011

Conversation

juno
Copy link
Contributor

@juno juno commented Feb 17, 2011

以下のようなモデルを定義した場合に、

class Item
  include Mongoid::Document
  field :name
  paginates_per 10
end

以下のように動作することを確認しています。

>> Item.order_by(:_id.asc).page(1).each{|i| puts i.name }
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 7
Item 8
Item 9
Item 10
=> #<Mongoid::Criteria
  selector: {},
  options:  {:sort=>[[:_id, :asc]], :limit=>10, :skip=>0},
  class:    Item,
  embedded: false>

ヘルパーもひと通り動いているようです。

現時点で気になっているのが以下の点です。

  • Mongoid::DocumentMongoid::Criteriaの両方に対して似たような処理をしている
  • MongoidではItem.page(1)の場合はDocumentが、Item.where(...).page(1)のような場合はCriteriaが返るため
  • Kaminari::Mongoid::Criteriaに対してpage以外のメソッドもフラットに定義している
  • Criteriaにはscopeが無いようなのでとりあえずこうしています
  • specが無い
  • spec/fake_app.rbにMongoid用のコードを入れるとrake spec時にMongoDBが必要になってしまうので現状ノータッチです

まだまだ課題が残る感じですが、とりあえず取り込んでいただければ追々進めていけるかなと思っていますので。よろしくお願いします。

@amatsuda
Copy link
Member

おおおおお。こんな時間までありがとうございます!!
というか、もしかして急かしてしまったようだったら申し訳ありません。。。

@amatsuda
Copy link
Member

いただきました。ありがとうございます!

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants