Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-2054

Override Id creation

    • Type: Icon: Task Task
    • Resolution: Done
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      I know that mongo allows to use an object as object id. However I can't find a way to do it, is it a mongoid limitation ?

      Here is what I expected :

      Lesson.find_or_create_by(:_id => {
        :i => BSON::ObjectId.new,
        :week => 23
      })
      
      
      # I get : 
      # {"_id":"4fc788f3f73147f19500005a"}
      # When I should get :
      # {"_id" => {"i" => BSON::ObjectId('4fc788f3f73147f19500005a'), "week" => 23}}
      
      

      Thx for your help.

            Assignee:
            Unassigned Unassigned
            Reporter:
            jjaffeux jjaffeux
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: