Native Object Client
    Preparing search index...

    Function patchNativeObject

    • Patches a native object

      Type Parameters

      • T = any

      Parameters

      • uri: string & $brand<"primaryKeyUri">
      • body: (
            | {
                path: string;
                value: string
                | number
                | boolean
                | any[]
                | Record<string, any>
                | null;
                op: "add";
            }
            | {
                path: string;
                value: string
                | number
                | boolean
                | any[]
                | Record<string, any>
                | null;
                op: "set";
            }
            | {
                path: string;
                value: string
                | number
                | boolean
                | any[]
                | Record<string, any>
                | null;
                op: "replace";
            }
            | { path: string; value: number; op: "incr" }
            | { path: string; value: number; op: "increment" }
            | { path: string; op: "remove" }
        )[]
      • opts: Options = {}

      Returns Promise<T>

      The following example shows the patching of a my-type native object instance with a primary key of foo:

      import { patchNativeObject, primaryKeyUriString } from "@contextual-io/native-object-client"

      const patchedObject = await patchNativeObject(
      primaryKeyUriString("my-type/foo"),
      [
      { "op": "incr", "path": "/someField", "value": 2 },
      ],
      )