gaqaround.blogg.se

Rails mongodb windows
Rails mongodb windows








The thing is that reduce is not called if only one emit has been done for particular key (in my example course_id has been played only once) so it is better to emit documents in the same format as result. Which would result in following result: [ as it does not matter that much and I could have just emitted empty document or anything and then always add 1 to the unt for every value. Map_reduce(map, reduce).out(inline: true) Self.where(:created_at.gt => Date.today, status: "played").

rails mongodb windows

So you could define the following method in your model ( ) def self.today Is there a clean way to do this?Īs mentioned in comments you can use map/reduce for this purpose. I could run through the table using each, and hack together some map or hash in rails with incrementation, but what if the course has 1 million views, retrieving and iterating over a million records could be messy.

rails mongodb windows

I believe mongodb has one now, but I'm unsure of how that would be done in rails 3. The issue is I don't see a group by method in Mongoid. I would therefore be using the created_at timestamp field, with course_id and action. So for example.Ĩ/1/12 had 2 plays, 8/2/12 had 6 plays. I want to get a daily count of total # of plays for a course. class Statisticįield :status, type: String # currently this is either play or complete Includes Ruby and Rails samples on both the Windows Server Core or Nano.

  • and timestamp information using Mongoid's Timestamping feature Only the Windows based container operating system images will run on Windows.
  • rails mongodb windows

    status which is a string, played or completed.I have a mongo table that has statistical data like the following.










    Rails mongodb windows