# Display/edit a nested document

This example shows you how to use a smart field to display and update a nested document.

Nested document in Forest Admin are not visible in the table view and are are displayed as a JSON in the details view. To make the document information more visible you can choose to display a smart field.

![](/files/-M3Mc6PIhnlW4ipZUvmD)

## Requirements <a href="#requirements" id="requirements"></a>

* An admin backend running on forest-express-mongoose

## How it works

### Directory: /models

This directory contains the `users.js` file where the model is declared.

{% code title="/models/users.js" %}

```javascript
const mongoose = require('mongoose');

const schema = mongoose.Schema({
  'person': {
    firstname: String,
    lastname: String,
    email: String,
  },
}, {
  timestamps: false,
});

module.exports = mongoose.model('users', schema, 'users');
```

{% endcode %}

### Directory: /forest

This directory contains the `users.js` file where the Smart Field `fistname`is declared.

{% code title="/forest/users.js" %}

```javascript
const { collection } = require('forest-express-mongoose');

collection('users', {
  fields: [{
    field: 'firstname',
    type: 'String',
    // Display the firstname
    get: (user) => {
      return user.person.firstname;
    },
    // Edit the firstname
    set: ((user, value) => {
      if (!user.person) {
        user.person = {};
      }
      user.person.firstname = value;
    })
  }],
});
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.forestadmin.com/woodshop/how-tos/display-edit-a-nested-document.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
