• Use the request's EntityManager.

    This function is intended for use in island components.

    Unlike its "utils" counterpart of the same name, it does not automatically fork the ORM instance. The ORM instance must have been forked previously with the other function, at any point in which it has access to the request event. These include a "request" hook from a Nitro plugin, a Nuxt server plugin, or a defineRequestEvent() handler function. Only then, this function can access that fork.

    Depending on the current runtimeConfig (see ModuleOptions), the utils function may be automatically called for all routes, making this one always available.

    Type Parameters

    • T extends EntityManager<IDatabaseDriver<Connection>> = EntityManager<IDatabaseDriver<Connection>>

      Type of the EntityManager instance. Typically, the "EntityManager" export of your MikroORM driver.

    Parameters

    • event: H3Event<EventHandlerRequest>

      The associated request of the EntityManager. Mostly kept for consistency with the "utils" counterpart.

    • name: string = 'default'

      The name of the MikroORM instance to fork.

    Returns T

    The request's associated EntityManager fork.

    Throws

    NuxtMikroOrmForkUnavailable When trying to use an instance that wasn't forked previously.