Module: Mongoid

Extended by:
Mongoid, Loggable
Included in:
Mongoid
Defined in:
lib/mongoid.rb,
lib/mongoid/atomic.rb,
lib/mongoid/config.rb,
lib/mongoid/fields.rb,
lib/mongoid/clients.rb,
lib/mongoid/factory.rb,
lib/mongoid/version.rb,
lib/mongoid/copyable.rb,
lib/mongoid/criteria.rb,
lib/mongoid/document.rb,
lib/mongoid/equality.rb,
lib/mongoid/findable.rb,
lib/mongoid/loggable.rb,
lib/mongoid/scopable.rb,
lib/mongoid/stateful.rb,
lib/mongoid/threaded.rb,
lib/mongoid/cacheable.rb,
lib/mongoid/evolvable.rb,
lib/mongoid/indexable.rb,
lib/mongoid/matchable.rb,
lib/mongoid/shardable.rb,
lib/mongoid/touchable.rb,
lib/mongoid/attributes.rb,
lib/mongoid/changeable.rb,
lib/mongoid/composable.rb,
lib/mongoid/contextual.rb,
lib/mongoid/positional.rb,
lib/mongoid/reloadable.rb,
lib/mongoid/selectable.rb,
lib/mongoid/timestamps.rb,
lib/mongoid/association.rb,
lib/mongoid/persistable.rb,
lib/mongoid/query_cache.rb,
lib/mongoid/traversable.rb,
lib/mongoid/validatable.rb,
lib/mongoid/matchable/gt.rb,
lib/mongoid/matchable/in.rb,
lib/mongoid/matchable/lt.rb,
lib/mongoid/matchable/ne.rb,
lib/mongoid/matchable/or.rb,
lib/mongoid/serializable.rb,
lib/mongoid/interceptable.rb,
lib/mongoid/matchable/all.rb,
lib/mongoid/matchable/and.rb,
lib/mongoid/matchable/gte.rb,
lib/mongoid/matchable/lte.rb,
lib/mongoid/matchable/nin.rb,
lib/mongoid/matchable/nor.rb,
lib/mongoid/config/options.rb,
lib/mongoid/extensions/set.rb,
lib/mongoid/matchable/size.rb,
lib/mongoid/tasks/database.rb,
lib/mongoid/association/one.rb,
lib/mongoid/clients/factory.rb,
lib/mongoid/clients/options.rb,
lib/mongoid/contextual/none.rb,
lib/mongoid/errors/callback.rb,
lib/mongoid/extensions/date.rb,
lib/mongoid/extensions/hash.rb,
lib/mongoid/extensions/time.rb,
lib/mongoid/fields/standard.rb,
lib/mongoid/association/many.rb,
lib/mongoid/atomic/modifiers.rb,
lib/mongoid/clients/sessions.rb,
lib/mongoid/contextual/mongo.rb,
lib/mongoid/criteria/options.rb,
lib/mongoid/errors/no_parent.rb,
lib/mongoid/extensions/array.rb,
lib/mongoid/extensions/float.rb,
lib/mongoid/extensions/range.rb,
lib/mongoid/fields/localized.rb,
lib/mongoid/matchable/exists.rb,
lib/mongoid/matchable/regexp.rb,
lib/mongoid/timestamps/short.rb,
lib/mongoid/association/proxy.rb,
lib/mongoid/atomic/paths/root.rb,
lib/mongoid/attributes/nested.rb,
lib/mongoid/contextual/atomic.rb,
lib/mongoid/contextual/memory.rb,
lib/mongoid/criteria/findable.rb,
lib/mongoid/criteria/scopable.rb,
lib/mongoid/errors/eager_load.rb,
lib/mongoid/extensions/module.rb,
lib/mongoid/extensions/object.rb,
lib/mongoid/extensions/regexp.rb,
lib/mongoid/extensions/string.rb,
lib/mongoid/extensions/symbol.rb,
lib/mongoid/matchable/default.rb,
lib/mongoid/association/macros.rb,
lib/mongoid/association/nested.rb,
lib/mongoid/attributes/dynamic.rb,
lib/mongoid/config/environment.rb,
lib/mongoid/contextual/command.rb,
lib/mongoid/criteria/queryable.rb,
lib/mongoid/errors/no_metadata.rb,
lib/mongoid/errors/validations.rb,
lib/mongoid/extensions/boolean.rb,
lib/mongoid/extensions/integer.rb,
lib/mongoid/fields/foreign_key.rb,
lib/mongoid/threaded/lifecycle.rb,
lib/mongoid/timestamps/created.rb,
lib/mongoid/timestamps/updated.rb,
lib/mongoid/validatable/format.rb,
lib/mongoid/validatable/length.rb,
lib/mongoid/validatable/macros.rb,
lib/mongoid/association/options.rb,
lib/mongoid/attributes/readonly.rb,
lib/mongoid/contextual/geo_near.rb,
lib/mongoid/criteria/includable.rb,
lib/mongoid/criteria/modifiable.rb,
lib/mongoid/criteria/permission.rb,
lib/mongoid/errors/invalid_find.rb,
lib/mongoid/errors/invalid_path.rb,
lib/mongoid/errors/invalid_time.rb,
lib/mongoid/persistable/logical.rb,
lib/mongoid/persistable/savable.rb,
lib/mongoid/persistence_context.rb,
lib/mongoid/timestamps/timeless.rb,
lib/mongoid/association/bindable.rb,
lib/mongoid/association/builders.rb,
lib/mongoid/contextual/queryable.rb,
lib/mongoid/criteria/marshalable.rb,
lib/mongoid/errors/invalid_field.rb,
lib/mongoid/errors/invalid_index.rb,
lib/mongoid/errors/invalid_scope.rb,
lib/mongoid/errors/invalid_value.rb,
lib/mongoid/errors/mongoid_error.rb,
lib/mongoid/errors/unknown_model.rb,
lib/mongoid/extensions/date_time.rb,
lib/mongoid/extensions/nil_class.rb,
lib/mongoid/extensions/object_id.rb,
lib/mongoid/matchable/elem_match.rb,
lib/mongoid/persistable/poppable.rb,
lib/mongoid/persistable/pullable.rb,
lib/mongoid/persistable/pushable.rb,
lib/mongoid/persistable/settable.rb,
lib/mongoid/validatable/presence.rb,
lib/mongoid/association/accessors.rb,
lib/mongoid/association/depending.rb,
lib/mongoid/association/relatable.rb,
lib/mongoid/atomic/paths/embedded.rb,
lib/mongoid/attributes/processing.rb,
lib/mongoid/contextual/map_reduce.rb,
lib/mongoid/errors/no_environment.rb,
lib/mongoid/extensions/decimal128.rb,
lib/mongoid/extensions/true_class.rb,
lib/mongoid/persistable/creatable.rb,
lib/mongoid/persistable/deletable.rb,
lib/mongoid/persistable/renamable.rb,
lib/mongoid/persistable/updatable.rb,
lib/mongoid/validatable/queryable.rb,
lib/mongoid/association/nested/one.rb,
lib/mongoid/criteria/queryable/key.rb,
lib/mongoid/errors/invalid_options.rb,
lib/mongoid/errors/mixed_relations.rb,
lib/mongoid/errors/no_client_hosts.rb,
lib/mongoid/errors/scope_overwrite.rb,
lib/mongoid/extensions/big_decimal.rb,
lib/mongoid/extensions/false_class.rb,
lib/mongoid/persistable/unsettable.rb,
lib/mongoid/persistable/upsertable.rb,
lib/mongoid/validatable/associated.rb,
lib/mongoid/validatable/uniqueness.rb,
lib/mongoid/association/marshalable.rb,
lib/mongoid/association/nested/many.rb,
lib/mongoid/association/reflections.rb,
lib/mongoid/clients/storage_options.rb,
lib/mongoid/errors/invalid_includes.rb,
lib/mongoid/errors/invalid_relation.rb,
lib/mongoid/errors/no_client_config.rb,
lib/mongoid/errors/unsaved_document.rb,
lib/mongoid/fields/validators/macro.rb,
lib/mongoid/persistable/destroyable.rb,
lib/mongoid/validatable/localizable.rb,
lib/mongoid/config/validators/client.rb,
lib/mongoid/config/validators/option.rb,
lib/mongoid/criteria/queryable/smash.rb,
lib/mongoid/errors/inverse_not_found.rb,
lib/mongoid/errors/no_clients_config.rb,
lib/mongoid/errors/no_default_client.rb,
lib/mongoid/errors/readonly_document.rb,
lib/mongoid/errors/unknown_attribute.rb,
lib/mongoid/timestamps/created/short.rb,
lib/mongoid/timestamps/updated/short.rb,
lib/mongoid/association/constrainable.rb,
lib/mongoid/atomic/paths/embedded/one.rb,
lib/mongoid/errors/delete_restriction.rb,
lib/mongoid/errors/document_not_found.rb,
lib/mongoid/errors/invalid_collection.rb,
lib/mongoid/errors/no_client_database.rb,
lib/mongoid/errors/readonly_attribute.rb,
lib/mongoid/extensions/time_with_zone.rb,
lib/mongoid/persistable/incrementable.rb,
lib/mongoid/association/eager_loadable.rb,
lib/mongoid/atomic/paths/embedded/many.rb,
lib/mongoid/clients/validators/storage.rb,
lib/mongoid/criteria/queryable/options.rb,
lib/mongoid/errors/invalid_session_use.rb,
lib/rails/generators/mongoid_generator.rb,
lib/mongoid/association/embedded/cyclic.rb,
lib/mongoid/contextual/aggregable/mongo.rb,
lib/mongoid/criteria/queryable/optional.rb,
lib/mongoid/criteria/queryable/pipeline.rb,
lib/mongoid/criteria/queryable/selector.rb,
lib/mongoid/errors/invalid_field_option.rb,
lib/mongoid/errors/no_map_reduce_output.rb,
lib/mongoid/association/referenced/eager.rb,
lib/mongoid/contextual/aggregable/memory.rb,
lib/mongoid/criteria/queryable/macroable.rb,
lib/mongoid/criteria/queryable/mergeable.rb,
lib/mongoid/errors/invalid_config_option.rb,
lib/mongoid/indexable/validators/options.rb,
lib/mongoid/criteria/queryable/aggregable.rb,
lib/mongoid/criteria/queryable/selectable.rb,
lib/mongoid/errors/ambiguous_relationship.rb,
lib/mongoid/errors/document_not_destroyed.rb,
lib/mongoid/errors/invalid_storage_parent.rb,
lib/mongoid/errors/unsupported_javascript.rb,
lib/mongoid/association/embedded/batchable.rb,
lib/mongoid/association/referenced/has_one.rb,
lib/mongoid/criteria/queryable/forwardable.rb,
lib/mongoid/errors/invalid_relation_option.rb,
lib/mongoid/errors/invalid_storage_options.rb,
lib/mongoid/association/embedded/embeds_one.rb,
lib/mongoid/association/referenced/has_many.rb,
lib/mongoid/association/referenced/syncable.rb,
lib/mongoid/association/embedded/embedded_in.rb,
lib/mongoid/association/embedded/embeds_many.rb,
lib/mongoid/association/referenced/auto_save.rb,
lib/mongoid/association/referenced/belongs_to.rb,
lib/mongoid/criteria/queryable/extensions/set.rb,
lib/mongoid/errors/invalid_dependent_strategy.rb,
lib/mongoid/errors/invalid_persistence_option.rb,
lib/mongoid/errors/mixed_client_configuration.rb,
lib/mongoid/criteria/queryable/extensions/date.rb,
lib/mongoid/criteria/queryable/extensions/hash.rb,
lib/mongoid/criteria/queryable/extensions/time.rb,
lib/mongoid/association/nested/nested_buildable.rb,
lib/mongoid/criteria/queryable/extensions/array.rb,
lib/mongoid/criteria/queryable/extensions/range.rb,
lib/mongoid/association/referenced/counter_cache.rb,
lib/mongoid/association/referenced/has_one/eager.rb,
lib/mongoid/association/referenced/has_one/proxy.rb,
lib/mongoid/criteria/queryable/extensions/object.rb,
lib/mongoid/criteria/queryable/extensions/regexp.rb,
lib/mongoid/criteria/queryable/extensions/string.rb,
lib/mongoid/criteria/queryable/extensions/symbol.rb,
lib/mongoid/association/embedded/embeds_one/proxy.rb,
lib/mongoid/association/referenced/has_many/eager.rb,
lib/mongoid/association/referenced/has_many/proxy.rb,
lib/mongoid/criteria/queryable/extensions/boolean.rb,
lib/mongoid/criteria/queryable/extensions/numeric.rb,
lib/mongoid/association/embedded/embedded_in/proxy.rb,
lib/mongoid/association/embedded/embeds_many/proxy.rb,
lib/mongoid/association/referenced/has_one/binding.rb,
lib/rails/generators/mongoid/model/model_generator.rb,
lib/mongoid/association/embedded/embeds_one/binding.rb,
lib/mongoid/association/referenced/belongs_to/eager.rb,
lib/mongoid/association/referenced/belongs_to/proxy.rb,
lib/mongoid/association/referenced/has_many/binding.rb,
lib/mongoid/criteria/queryable/extensions/date_time.rb,
lib/mongoid/criteria/queryable/extensions/nil_class.rb,
lib/mongoid/errors/invalid_set_polymorphic_relation.rb,
lib/mongoid/association/embedded/embedded_in/binding.rb,
lib/mongoid/association/embedded/embeds_many/binding.rb,
lib/mongoid/association/referenced/has_one/buildable.rb,
lib/mongoid/errors/in_memory_collation_not_supported.rb,
lib/mongoid/errors/too_many_nested_attribute_records.rb,
lib/rails/generators/mongoid/config/config_generator.rb,
lib/mongoid/association/embedded/embeds_one/buildable.rb,
lib/mongoid/association/referenced/belongs_to/binding.rb,
lib/mongoid/association/referenced/has_many/buildable.rb,
lib/mongoid/criteria/queryable/extensions/big_decimal.rb,
lib/mongoid/association/embedded/embedded_in/buildable.rb,
lib/mongoid/association/embedded/embeds_many/buildable.rb,
lib/mongoid/association/referenced/has_many/enumerable.rb,
lib/mongoid/association/referenced/belongs_to/buildable.rb,
lib/mongoid/errors/nested_attributes_metadata_not_found.rb,
lib/mongoid/criteria/queryable/extensions/time_with_zone.rb,
lib/mongoid/association/referenced/has_one/nested_builder.rb,
lib/mongoid/association/referenced/has_and_belongs_to_many.rb,
lib/mongoid/association/referenced/has_and_belongs_to_many/eager.rb,
lib/mongoid/association/referenced/has_and_belongs_to_many/proxy.rb,
lib/mongoid/association/referenced/has_and_belongs_to_many/binding.rb,
lib/mongoid/association/referenced/has_and_belongs_to_many/buildable.rb

Defined Under Namespace

Modules: Association, Atomic, Attributes, Cacheable, Changeable, Clients, Composable, Config, Contextual, Copyable, Document, Equality, Errors, Evolvable, Extensions, Factory, Fields, Findable, Generators, Indexable, Interceptable, Loggable, Matchable, Persistable, Positional, QueryCache, Reloadable, Scopable, Selectable, Serializable, Shardable, Stateful, Tasks, Threaded, Timestamps, Touchable, Traversable, Validatable Classes: Boolean, Criteria, PersistenceContext

Constant Summary collapse

PLATFORM_DETAILS =

A string added to the platform details of Ruby driver client handshake documents.

Since:

  • 6.1.0

"mongoid-#{VERSION}".freeze
MONGODB_VERSION =

The minimum MongoDB version supported.

"2.6.0"
VERSION =
"7.0.2"

Instance Method Summary collapse

Methods included from Loggable

logger, logger=

Instance Method Details

#client(name) ⇒ Mongo::Client

Convenience method for getting a named client.

Examples:

Get a named client.

Mongoid.client(:default)

Returns:

  • (Mongo::Client)

    The named client.

Since:

  • 5.0.0



93
94
95
# File 'lib/mongoid.rb', line 93

def client(name)
  Clients.with_name(name)
end

#configureConfig

Sets the Mongoid configuration options. Best used by passing a block.

Examples:

Set up configuration options.

Mongoid.configure do |config|
  config.connect_to("mongoid_test")
end

Returns:

  • (Config)

    The configuration object.

Since:

  • 1.0.0



57
58
59
# File 'lib/mongoid.rb', line 57

def configure
  block_given? ? yield(Config) : Config
end

#default_clientMongo::Client

Convenience method for getting the default client.

Examples:

Get the default client.

Mongoid.default_client

Returns:

  • (Mongo::Client)

    The default client.

Since:

  • 5.0.0



69
70
71
# File 'lib/mongoid.rb', line 69

def default_client
  Clients.default
end

#disconnect_clientstrue

Disconnect all active clients.

Examples:

Disconnect all active clients.

Mongoid.disconnect_clients

Returns:

  • (true)

    True.

Since:

  • 5.0.0



81
82
83
# File 'lib/mongoid.rb', line 81

def disconnect_clients
  Clients.disconnect
end