> This page location: /docs.md > /docs/drivers.md > /docs/languages/ruby.md > /docs/mongoid/current.md

> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

# Use the Document Module in Your Model

## Overview

In this guide, you can learn about the `Mongoid::Document` module in Mongoid. The `Document` module is a Ruby implementation of a MongoDB document, which stores data in field-and-value pairs. To learn more about the terminology, structure, and limitations of MongoDB documents, see [Documents](https://www.mongodb.com/docs/manual/core/document/) in the Server manual.

You must include the `Mongoid::Document` module in any class that you want to persist to MongoDB. By including the `Document` module in your model class, you can use its methods on instances of your model class.

The following code demonstrates how to include the `Document` module in a sample `Person` model class:

```ruby
class Person
    include Mongoid::Document

    field :name, type: String
end
```

You can find more information about the `Document` module in the [API documentation.](https://www.mongodb.com/docs/mongoid/current/api/Mongoid/Document.html)

## Work with Documents

You can store instances of your models directly in a collection, or you can embed them in other classes that use the `Document` module. When you save a `Document` instance to MongoDB, it is converted to a BSON object that is similar to a Ruby hash or JSON object.

The following code creates an instance of the `Person` model defined in the preceding section:

```ruby
Person.create(name: 'Meena Kumar')
```

The document appears in MongoDB as follows:

```json
{
  "_id": {
    "$oid": "673b6dce61700598c24a72b0"
  },
  "name": "Meena Kumar"
}
```

**Note: \_id Field**

When you persist an instance of a model to the database, MongoDB automatically adds an `_id` field that has a unique value even if you do not explicitly define this field in your model.

To learn more about this field, see the [ObjectId reference](https://www.mongodb.com/docs/manual/reference/bson-types/#objectid) in the Server manual.

## Additional Information

To learn more about the field types that you can use in Mongoid models, see the [Use BSON Field Types](https://www.mongodb.com/docs/mongoid/current/data-modeling/field-types.md#std-label-mongoid-field-types) guide.

To learn how to access and change your MongoDB data, see [CRUD Operations.](https://www.mongodb.com/docs/mongoid/current/interact-data/crud.md#std-label-mongoid-interact-data)
