Method: Mongoid::Fields::ClassMethods#id_fields

Defined in:
lib/mongoid/fields.rb

#id_fieldsArray<Symbol | String>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the list of id fields for this model class, as both strings and symbols.

Returns:

  • (Array<Symbol | String>)

    List of id fields.



64
65
66
67
68
69
70
71
72
73
# File 'lib/mongoid/fields.rb', line 64

def id_fields
  IDS.dup.tap do |id_fields|
    aliased_fields.each do |k, v|
      if v == '_id'
        id_fields << k.to_sym
        id_fields << k
      end
    end
  end
end