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

Custom keys for associations MONGOID-1851

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.1.0
    • Affects Version/s: None
    • Component/s: None
    • None

      Relations now have one more option,

      Unable to find source-code formatter for language: primary_key```. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      
      Given those models
      

      ruby
      class Person
      include Mongoid::Document

      field :username
      has_many :cats, primary_key: :username
      end

      
      

      ruby
      class Cat
      include Mongoid::Document

      field :name
      belongs_to :person, primary_key: :username
      end

      
      

      ruby
      crazy_lady = Person.create!
      20.times

      { crazy_lady.cats.create! }
      
      this will create 20 cats, and the fk, on Cat, 

      person_id{{`}}, will be the username.

            Assignee:
            durran Durran Jordan
            Reporter:
            arthurnn Arthur Nogueira Neves
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: