0

can u help me pls as i surfed around but didn't find any information. I'm working with mongoDB capped collection using Ruby. I need to update documents according to the id i retrieve from the query, but it never works. here is the example of my code

cursor = coll.find({"EndTime" => nil})

begin

  while row = cursor.next_document
    if !alive row["Pid"]
      coll.update({"_id"=>row["_id"]}, { "$set" =>  { "EndTime" =>Time.now}})
    end
  end

rescue

end

thanx a lot

Mark Thomas
  • 37,131
  • 11
  • 74
  • 101
Kuen
  • 163
  • 2
  • 4
  • 13
  • It would be helpful if you could explain a bit more what it is that isn't working, it's not as if we can run your code. What does the `alive` method do, for example. Isn't it just the case that the if statement is never true? – Theo Jan 10 '11 at 18:02

1 Answers1

3

Objects in a capped collection are not allowed to grow. Make sure that when you insert you already have space for "EndTime" preallocated.

mstearn
  • 4,156
  • 1
  • 19
  • 18