# States Registry

As you might have noticed by now, [routing instructions](/frrri/ngxs-crud/usage/routing-instructions.md) and [ui components](/frrri/ngxs-crud/usage/ui-components.md) use state paths to specify a collection.

```typescript
@CrudCollection({
    name: 'posts'
})
export class PostsState extends CrudCollectionState { }

@CrudEntities({
    name: 'entities',
    children: [PostsState]
})
export class EntitiesState extends CrudEntitiesState { }
```

The **PostsState** collection can now be access via the path `entities.posts`. Retrieving the correct state is handled by the **StatesRegistryService**.

## StatesRegistryService

The service exposes a function called `getByPath(path: string)` that lets you retrieve states via their path mapping. The mapping is automatically generated via the **name attribute** in the decorator options. Nesting is performed by the **children array** in the decorator options.

```typescript
import { StatesRegistryService } from '@frrri/ngxs-crud/registry';

@Component(...)
export class AppComponent {

    constructor(private registry: StatesRegistryService) {
        const entitiesState = this.registry.getByPath<EntitiesState>('entities');
        const postsState = this.registry.getByPath<PostsState>('entities.posts');
        ...
    }

}
```


---

# 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://bitflut.gitbook.io/frrri/ngxs-crud/recipes/states-registry.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.
