Toshihiko
    検索インデックスを準備しています...

    インターフェイス Query<Name, Schema, AdapterInstance>

    1 回のデータベース操作を表す、変更可能でチェーン可能な記述です。

    builder メソッドは現在の Query 状態を置換または拡張し、同じインスタンスを返します。独立した 2 回の操作で条件、フィールド、limit、接続が異なる場合は、Model から新しく始めてください。

    interface Query<
        Name extends string,
        Schema extends SchemaDefinition,
        AdapterInstance extends AdapterLike = Adapter,
    > {
        field: (
            fields:
                | string
                | readonly Extract<keyof RowFromSchema<Schema>, string>[],
        ) => this;
        orderBy: (order: QueryOrder<RowFromSchema<Schema>>) => this;
        conn(
            connection:
                | Exclude<Parameters<AdapterInstance["insert"]>[1], null>
                | null,
        ): this;
        count(): Promise<number>;
        delete(): Promise<AdapterDeleteByQueryResult<AdapterInstance>>;
        execute(
            ...arguments_: AdapterQueryExecuteArguments<AdapterInstance>,
        ): Promise<AdapterExecuteResult<AdapterInstance>>;
        fields(
            fields:
                | string
                | readonly Extract<keyof RowFromSchema<Schema>, string>[],
        ): this;
        find(): Promise<readonly QueriedYukari<Name, Schema, AdapterInstance>[]>;
        find(
            options: QueryFindManyOptions,
        ): Promise<readonly QueriedYukari<Name, Schema, AdapterInstance>[]>;
        find(
            options: QueryFindOneOptions,
        ): Promise<QueriedYukari<Name, Schema, AdapterInstance> | null>;
        find(
            toJSON: false,
            options?: QueryFindManyOptions,
        ): Promise<readonly QueriedYukari<Name, Schema, AdapterInstance>[]>;
        find(
            toJSON: false,
            options: QueryFindOneOptions,
        ): Promise<QueriedYukari<Name, Schema, AdapterInstance> | null>;
        find(
            toJSON: true,
            options?: QueryFindManyOptions,
        ): Promise<readonly Partial<JsonRowFromSchema<Schema>>[]>;
        find(
            toJSON: true,
            options: QueryFindOneOptions,
        ): Promise<Partial<JsonRowFromSchema<Schema>> | null>;
        find(
            options: QueryFindManyOptions,
            toJSON: true,
        ): Promise<readonly Partial<JsonRowFromSchema<Schema>>[]>;
        find(
            options: QueryFindOneOptions,
            toJSON: false,
        ): Promise<QueriedYukari<Name, Schema, AdapterInstance> | null>;
        find(
            options: QueryFindOneOptions,
            toJSON: true,
        ): Promise<Partial<JsonRowFromSchema<Schema>> | null>;
        findById(
            id: FindByIdInput<Schema>,
        ): Promise<QueriedYukari<Name, Schema, AdapterInstance> | null>;
        findById(
            id: FindByIdInput<Schema>,
            toJSON: false,
        ): Promise<QueriedYukari<Name, Schema, AdapterInstance> | null>;
        findById(
            id: FindByIdInput<Schema>,
            toJSON: true,
        ): Promise<Partial<JsonRowFromSchema<Schema>> | null>;
        findOne(): Promise<QueriedYukari<Name, Schema, AdapterInstance> | null>;
        findOne(
            toJSON: false,
        ): Promise<QueriedYukari<Name, Schema, AdapterInstance> | null>;
        findOne(toJSON: true): Promise<Partial<JsonRowFromSchema<Schema>> | null>;
        index(indexName: string): this;
        limit(limit: string | number | readonly (string | number)[]): this;
        limit(offset: string | number, count: string | number): this;
        order(order: QueryOrder<RowFromSchema<Schema>>): this;
        update(
            data: Partial<RowFromSchema<Schema>>,
            ...support: AdapterUpdateByQueryCallArguments<AdapterInstance>,
        ): Promise<AdapterUpdateByQueryResult<AdapterInstance>>;
        where(condition: QueryWhere<RowFromSchema<Schema>>): this;
    }

    型パラメーター

    インデックス
    field: (
        fields: string | readonly Extract<keyof RowFromSchema<Schema>, string>[],
    ) => this

    fields の互換エイリアスです。

    orderBy: (order: QueryOrder<RowFromSchema<Schema>>) => this

    order の互換エイリアスです。

    • 以降の実行で使用するトランザクション接続を選択します。

      パラメータ

      • connection: Exclude<Parameters<AdapterInstance["insert"]>[1], null> | null

        Adapter 固有の接続です。null の場合は Adapter の既定の接続方法を使用します。

      戻り値 this

      現在の Query です。

    • 現在の条件に一致するデータ行数を数えます。

      戻り値 Promise<number>

      Adapter が報告した件数です。

    • 選択するフィールドを置き換えます。

      文字列はカンマで分割され、前後の空白が除去されます。配列では schema のフィールド名を検査します。文字列は Adapter 互換の式にも使用できます。

      パラメータ

      • fields: string | readonly Extract<keyof RowFromSchema<Schema>, string>[]

        カンマ区切りの式、または論理フィールド名です。

      戻り値 this

      現在の Query です。

      実行時の値が文字列でも配列でもない場合です。

    • 現在の Query 状態を使用してデータ行を検索します。

      既定では Yukari のデータ行の配列を返します。true を渡すと、Field Type を介してシリアライズされた plain object を返します。single: true は結果を 1 件だけ要求し、戻り値の型を 1 行または null に変更します。noCache: true はクエリキャッシュを使用しないよう Adapter に指示します。boolean とオプションオブジェクトは、対応するどちらの順序でも渡せます。

      戻り値 Promise<readonly QueriedYukari<Name, Schema, AdapterInstance>[]>

      既定では複数行、single: true の場合は 1 行です。

      await User.where({ active: true }).find();
      await User.where({ active: true }).find(true);
      await User.where({ active: true }).find({ single: true });
    • 現在の Query 状態を使用してデータ行を検索します。

      既定では Yukari のデータ行の配列を返します。true を渡すと、Field Type を介してシリアライズされた plain object を返します。single: true は結果を 1 件だけ要求し、戻り値の型を 1 行または null に変更します。noCache: true はクエリキャッシュを使用しないよう Adapter に指示します。boolean とオプションオブジェクトは、対応するどちらの順序でも渡せます。

      パラメータ

      戻り値 Promise<readonly QueriedYukari<Name, Schema, AdapterInstance>[]>

      既定では複数行、single: true の場合は 1 行です。

      await User.where({ active: true }).find();
      await User.where({ active: true }).find(true);
      await User.where({ active: true }).find({ single: true });
    • 現在の Query 状態を使用してデータ行を検索します。

      既定では Yukari のデータ行の配列を返します。true を渡すと、Field Type を介してシリアライズされた plain object を返します。single: true は結果を 1 件だけ要求し、戻り値の型を 1 行または null に変更します。noCache: true はクエリキャッシュを使用しないよう Adapter に指示します。boolean とオプションオブジェクトは、対応するどちらの順序でも渡せます。

      パラメータ

      戻り値 Promise<QueriedYukari<Name, Schema, AdapterInstance> | null>

      既定では複数行、single: true の場合は 1 行です。

      await User.where({ active: true }).find();
      await User.where({ active: true }).find(true);
      await User.where({ active: true }).find({ single: true });
    • 現在の Query 状態を使用してデータ行を検索します。

      既定では Yukari のデータ行の配列を返します。true を渡すと、Field Type を介してシリアライズされた plain object を返します。single: true は結果を 1 件だけ要求し、戻り値の型を 1 行または null に変更します。noCache: true はクエリキャッシュを使用しないよう Adapter に指示します。boolean とオプションオブジェクトは、対応するどちらの順序でも渡せます。

      パラメータ

      戻り値 Promise<readonly QueriedYukari<Name, Schema, AdapterInstance>[]>

      既定では複数行、single: true の場合は 1 行です。

      await User.where({ active: true }).find();
      await User.where({ active: true }).find(true);
      await User.where({ active: true }).find({ single: true });
    • 現在の Query 状態を使用してデータ行を検索します。

      既定では Yukari のデータ行の配列を返します。true を渡すと、Field Type を介してシリアライズされた plain object を返します。single: true は結果を 1 件だけ要求し、戻り値の型を 1 行または null に変更します。noCache: true はクエリキャッシュを使用しないよう Adapter に指示します。boolean とオプションオブジェクトは、対応するどちらの順序でも渡せます。

      パラメータ

      戻り値 Promise<QueriedYukari<Name, Schema, AdapterInstance> | null>

      既定では複数行、single: true の場合は 1 行です。

      await User.where({ active: true }).find();
      await User.where({ active: true }).find(true);
      await User.where({ active: true }).find({ single: true });
    • 現在の Query 状態を使用してデータ行を検索します。

      既定では Yukari のデータ行の配列を返します。true を渡すと、Field Type を介してシリアライズされた plain object を返します。single: true は結果を 1 件だけ要求し、戻り値の型を 1 行または null に変更します。noCache: true はクエリキャッシュを使用しないよう Adapter に指示します。boolean とオプションオブジェクトは、対応するどちらの順序でも渡せます。

      パラメータ

      戻り値 Promise<readonly Partial<JsonRowFromSchema<Schema>>[]>

      既定では複数行、single: true の場合は 1 行です。

      await User.where({ active: true }).find();
      await User.where({ active: true }).find(true);
      await User.where({ active: true }).find({ single: true });
    • 現在の Query 状態を使用してデータ行を検索します。

      既定では Yukari のデータ行の配列を返します。true を渡すと、Field Type を介してシリアライズされた plain object を返します。single: true は結果を 1 件だけ要求し、戻り値の型を 1 行または null に変更します。noCache: true はクエリキャッシュを使用しないよう Adapter に指示します。boolean とオプションオブジェクトは、対応するどちらの順序でも渡せます。

      パラメータ

      戻り値 Promise<Partial<JsonRowFromSchema<Schema>> | null>

      既定では複数行、single: true の場合は 1 行です。

      await User.where({ active: true }).find();
      await User.where({ active: true }).find(true);
      await User.where({ active: true }).find({ single: true });
    • 現在の Query 状態を使用してデータ行を検索します。

      既定では Yukari のデータ行の配列を返します。true を渡すと、Field Type を介してシリアライズされた plain object を返します。single: true は結果を 1 件だけ要求し、戻り値の型を 1 行または null に変更します。noCache: true はクエリキャッシュを使用しないよう Adapter に指示します。boolean とオプションオブジェクトは、対応するどちらの順序でも渡せます。

      パラメータ

      戻り値 Promise<readonly Partial<JsonRowFromSchema<Schema>>[]>

      既定では複数行、single: true の場合は 1 行です。

      await User.where({ active: true }).find();
      await User.where({ active: true }).find(true);
      await User.where({ active: true }).find({ single: true });
    • 現在の Query 状態を使用してデータ行を検索します。

      既定では Yukari のデータ行の配列を返します。true を渡すと、Field Type を介してシリアライズされた plain object を返します。single: true は結果を 1 件だけ要求し、戻り値の型を 1 行または null に変更します。noCache: true はクエリキャッシュを使用しないよう Adapter に指示します。boolean とオプションオブジェクトは、対応するどちらの順序でも渡せます。

      パラメータ

      戻り値 Promise<QueriedYukari<Name, Schema, AdapterInstance> | null>

      既定では複数行、single: true の場合は 1 行です。

      await User.where({ active: true }).find();
      await User.where({ active: true }).find(true);
      await User.where({ active: true }).find({ single: true });
    • 現在の Query 状態を使用してデータ行を検索します。

      既定では Yukari のデータ行の配列を返します。true を渡すと、Field Type を介してシリアライズされた plain object を返します。single: true は結果を 1 件だけ要求し、戻り値の型を 1 行または null に変更します。noCache: true はクエリキャッシュを使用しないよう Adapter に指示します。boolean とオプションオブジェクトは、対応するどちらの順序でも渡せます。

      パラメータ

      戻り値 Promise<Partial<JsonRowFromSchema<Schema>> | null>

      既定では複数行、single: true の場合は 1 行です。

      await User.where({ active: true }).find();
      await User.where({ active: true }).find(true);
      await User.where({ active: true }).find({ single: true });
    • 主キー値で 1 行を検索します。

      主キーが 1 個の Model では値を直接渡せます。複合主キーにはオブジェクトが必要です。Cache が設定されている場合は、最初に Cache からの読み取りを試みます。Cache でエラーが発生した場合は Adapter へフォールバックします。

      パラメータ

      戻り値 Promise<QueriedYukari<Name, Schema, AdapterInstance> | null>

      一致するデータ行、または null です。

      主キーが 1 個だけではない Model にプリミティブ値の ID を渡した場合です。

    • 主キー値で 1 行を検索します。

      主キーが 1 個の Model では値を直接渡せます。複合主キーにはオブジェクトが必要です。Cache が設定されている場合は、最初に Cache からの読み取りを試みます。Cache でエラーが発生した場合は Adapter へフォールバックします。

      パラメータ

      • id: FindByIdInput<Schema>

        主キー値、または複合主キーオブジェクトです。

      • toJSON: false

      戻り値 Promise<QueriedYukari<Name, Schema, AdapterInstance> | null>

      一致するデータ行、または null です。

      主キーが 1 個だけではない Model にプリミティブ値の ID を渡した場合です。

    • 主キー値で 1 行を検索します。

      主キーが 1 個の Model では値を直接渡せます。複合主キーにはオブジェクトが必要です。Cache が設定されている場合は、最初に Cache からの読み取りを試みます。Cache でエラーが発生した場合は Adapter へフォールバックします。

      パラメータ

      • id: FindByIdInput<Schema>

        主キー値、または複合主キーオブジェクトです。

      • toJSON: true

      戻り値 Promise<Partial<JsonRowFromSchema<Schema>> | null>

      一致するデータ行、または null です。

      主キーが 1 個だけではない Model にプリミティブ値の ID を渡した場合です。

    • Adapter 固有のインデックスヒントを設定します。

      パラメータ

      • indexName: string

        解釈せずに Adapter へ渡すインデックス名です。

      戻り値 this

      現在の Query です。

    • 結果数、または offset と結果数を設定します。

      v1 との互換性のため、文字列と配列も受け付けます。値は 10 進整数として parse され、無効な値は 0 になります。配列では最大 2 項目を使用します。

      パラメータ

      • limit: string | number | readonly (string | number)[]

        件数、カンマ区切りの値、または [offset, count] です。

      戻り値 this

      現在の Query です。

    • limit - 件数、カンマ区切りの値、または [offset, count] です。

      パラメータ

      • offset: string | number
      • count: string | number

      戻り値 this

      現在の Query です。

    • 現在のソート順を置き換えます。

      オブジェクト形式では schema のフィールド名を検査します。文字列形式はカンマ区切りの Adapter 互換 order 式として parse されます。

      パラメータ

      • order: QueryOrder<RowFromSchema<Schema>>

        文字列、フィールドと方向のオブジェクト、またはいずれかの形式の配列です。

      戻り値 this

      現在の Query です。

    • 現在のクエリ条件を置き換えます。

      後の呼び出しは以前の条件とマージされません。1 個の条件に複数の分岐が必要な場合は、その条件内で $and または $or を使用してください。

      パラメータ

      戻り値 this

      現在の Query です。

      実行時の値がオブジェクトではない場合です。