Sanity Library Reference Docs
    Preparing search index...

    Interface NodeMigration

    Node migration helper functions. As the migration is processing a document, it will visit each node in the document, depth-first, call the appropriate helper function for the node type and collect any mutations returned from it.

    interface NodeMigration {
        array?: <Node extends JsonArray>(
            node: Node,
            path: Path,
            context: MigrationContext,
        ) =>
            | void
            | NodeMigrationReturnValue
            | Promise<(void | NodeMigrationReturnValue)>;
        boolean?: <Node extends boolean>(
            node: Node,
            path: Path,
            context: MigrationContext,
        ) =>
            | void
            | NodeMigrationReturnValue
            | Promise<(void | NodeMigrationReturnValue)>;
        document?: <Doc extends SanityDocument>(
            doc: Doc,
            context: MigrationContext,
        ) =>
            | void
            | Transaction
            | DocumentMigrationReturnValue
            | Promise<(Transaction | DocumentMigrationReturnValue)>;
        node?: <Node extends JsonValue>(
            node: Node,
            path: Path,
            context: MigrationContext,
        ) =>
            | void
            | NodeMigrationReturnValue
            | Promise<(void | NodeMigrationReturnValue)>;
        null?: <Node extends null>(
            node: Node,
            path: Path,
            context: MigrationContext,
        ) =>
            | void
            | NodeMigrationReturnValue
            | Promise<(void | NodeMigrationReturnValue)>;
        number?: <Node extends number>(
            node: Node,
            path: Path,
            context: MigrationContext,
        ) =>
            | void
            | NodeMigrationReturnValue
            | Promise<(void | NodeMigrationReturnValue)>;
        object?: <Node extends JsonObject>(
            node: Node,
            path: Path,
            context: MigrationContext,
        ) =>
            | void
            | NodeMigrationReturnValue
            | Promise<(void | NodeMigrationReturnValue)>;
        string?: <Node extends string>(
            node: Node,
            path: Path,
            context: MigrationContext,
        ) =>
            | void
            | NodeMigrationReturnValue
            | Promise<(void | NodeMigrationReturnValue)>;
    }
    Index

    Properties

    array?: <Node extends JsonArray>(
        node: Node,
        path: Path,
        context: MigrationContext,
    ) =>
        | void
        | NodeMigrationReturnValue
        | Promise<(void | NodeMigrationReturnValue)>

    Helper function that will be called for each array in each document included in the migration

    Type declaration

    boolean?: <Node extends boolean>(
        node: Node,
        path: Path,
        context: MigrationContext,
    ) =>
        | void
        | NodeMigrationReturnValue
        | Promise<(void | NodeMigrationReturnValue)>

    Helper function that will be called for each boolean value in each document included in the migration

    Type declaration

    document?: <Doc extends SanityDocument>(
        doc: Doc,
        context: MigrationContext,
    ) =>
        | void
        | Transaction
        | DocumentMigrationReturnValue
        | Promise<(Transaction | DocumentMigrationReturnValue)>

    Helper function for migrating a document as a whole

    Type declaration

    node?: <Node extends JsonValue>(
        node: Node,
        path: Path,
        context: MigrationContext,
    ) =>
        | void
        | NodeMigrationReturnValue
        | Promise<(void | NodeMigrationReturnValue)>

    Helper function that will be called for each node in each document included in the migration

    Type declaration

    null?: <Node extends null>(
        node: Node,
        path: Path,
        context: MigrationContext,
    ) =>
        | void
        | NodeMigrationReturnValue
        | Promise<(void | NodeMigrationReturnValue)>

    Helper function that will be called for each null value in each document included in the migration

    Type declaration

    number?: <Node extends number>(
        node: Node,
        path: Path,
        context: MigrationContext,
    ) =>
        | void
        | NodeMigrationReturnValue
        | Promise<(void | NodeMigrationReturnValue)>

    Helper function that will be called for each number in each document included in the migration

    Type declaration

    object?: <Node extends JsonObject>(
        node: Node,
        path: Path,
        context: MigrationContext,
    ) =>
        | void
        | NodeMigrationReturnValue
        | Promise<(void | NodeMigrationReturnValue)>

    Helper function that will be called for each object in each document included in the migration

    Type declaration

    string?: <Node extends string>(
        node: Node,
        path: Path,
        context: MigrationContext,
    ) =>
        | void
        | NodeMigrationReturnValue
        | Promise<(void | NodeMigrationReturnValue)>

    Helper function that will be called for each string in each document included in the migration

    Type declaration