NoSQLテーブルにアイテムを挿入
Catalystでは、アイテムを構築した後、特定のNoSQLテーブルにアイテムを挿入できます。このセクションで説明するように、アイテムはさまざまな方法で挿入できます。
データの追加と操作、CatalystカスタムJSON形式、およびサポートされるデータ型に関するヘルプセクションを参照して、これらのトピックの詳細を学ぶことができます。
条件なしでアイテムを挿入
ZCNoSQLTableインスタンス、またはリクエストの各部分を構築するために使用できるZCNoSQLInsertHelperインスタンスを使用して、条件なしでNoSQLテーブルに新しいアイテムを挿入できます。
以下に示すように、ZCNoSQLTableインスタンスでデータを挿入できます。
//public ZCNoSQLResponseBean insert(ZCNoSQLItem item) throws Exception;
table.insert(<ZCNoSQLItem>);
以下に示すように、ZCNoSQLInsertHelperインスタンスでデータを挿入できます。
//public ZCNoSQLInsertHelper getInsertHelper(ZCNoSQLItem item) throws Exception;
//public ZCNoSQLResponseBean insert() throws Exception;
table.getInsertHelper(<ZCNoSQLItem>).insert();
このクラスは、条件付きでテーブルにデータを挿入するために使用できます。ZCNoSQLTableインスタンスから取得できます。
条件付きでアイテムを挿入
定義した特定の条件を使用して、NoSQLテーブルの既存アイテムに属性を挿入できます。このタイプでは、テーブルの既存データが取得され、指定された条件に対して評価されます。評価がtrueの場合にのみアイテムが挿入されます。既存データがない場合、条件は無視されアイテムが挿入されます。
以下のスニペットは、ZCNoSQLConditionを使用した条件付きアイテムの挿入を示しています。
//public ZCNoSQLInsertHelper withCondition(ZCNoSQLCondition condition) throws Exception;
table.getInsertHelper(<ZCNoSQLItem>).withCondition(<ZCNoSQLCondition>).insert();
条件は、コンストラクタまたはgetInstance()メソッドを呼び出して取得できるZCNoSQLConditionインスタンスを使用して渡すことができます。条件は3つの方法で初期化できます。
1. 関数を使用する方法
//public static ZCNoSQLCondition getInstance(NoSQLConditionFunction function) throws Exception;
//public ZCNoSQLCondition(NoSQLConditionFunction function) throws Exception;
ZCNoSQLCondition.getInstance(<NoSQLCondtitionFunction>);
new ZCNoSQLCondition(<NoSQLCondtitionFunction>)
2つの組み込み関数が利用可能です。
i. ZCNoSQLAttributeTypeFunction
指定した属性のデータ型が指定したデータ型と一致するかどうかを確認します。
//public ZCNoSQLAttributeTypeFunction(ZCNoSQLAttribute attribute, ZCNoSQLValue.DataType dataType) throws Exception;
//public static ZCNoSQLAttributeTypeFunction getInstance(ZCNoSQLAttribute attribute, ZCNoSQLValue.DataType dataType) throws Exception;
ZCNoSQLAttributeTypeFunction.getInstance(<ZCNoSQLAttribute>, <ZCNoSQLValue.DataType>);
new ZCNoSQLAttributeTypeFunction(<ZCNoSQLAttribute>, <ZCNoSQLValue.DataType>);
ii. ZCNoSQLAttributeExistFunction
取得したアイテムに属性が既に存在するかどうかを評価するために使用されます。
//public ZCNoSQLAttributeExistFunction(ZCNoSQLAttribute attribute);
//public static ZCNoSQLAttributeExistFunction getInstance(ZCNoSQLAttribute attribute);
ZCNoSQLAttributeExistFunction.getInstance(<ZCNoSQLAttribute>);
new ZCNoSQLAttributeExistFunction(<ZCNoSQLAttribute>)
2. 演算子、オペランド、値を使用する方法
//public static ZCNoSQLCondition getInstance(ZCNoSQLAttribute attribute, NOSQL_OPERATOR operator, ZCNoSQLValue value) throws Exception;
//public ZCNoSQLCondition(ZCNoSQLAttribute attribute, NOSQL_OPERATOR operator, ZCNoSQLValue value) throws Exception;
ZCNoSQLCondition.getInstance(<ZCNoSQLAttribute>, <NOSQL_OPERATOR>, <ZCNoSQLValue>);
new ZCNoSQLCondition(<ZCNoSQLAttribute>, <NOSQL_OPERATOR>, <ZCNoSQLValue>);
NOSQL_OPERATOR
許可されるNOSQL_OPERATORの値は、contains、not_contains、begins_with、ends_with、in、not_in、between、not_between、equals、not_equals、greater_than、less_than、greater_equal、less_equalです。
条件のグループを使用する方法
//public static ZCNoSQLCondition getInstance(List<ZCNoSQLCondition> groups, NOSQL_CONDITION_GROUP_OPERATOR groupOperator) throws Exception;
//public ZCNoSQLCondition(List<ZCNoSQLCondition> groups, NOSQL_CONDITION_GROUP_OPERATOR groupOperator) throws Exception;
ZCNoSQLCondition.getInstance(List<ZCNoSQLCondition>,<NOSQL_CONDITION_GROUP_OPERATOR>)
new ZCNoSQLCondition(List<ZCNoSQLCondition>,<NOSQL_CONDITION_GROUP_OPERATOR>)
NOSQL_CONDITION_GROUP_OPERATOR
許可されるNOSQL_CONDITION_GROUP_OPERATORの値は、AND、ORです。
NOSQL_RETURN_VALUE
条件の評価後の戻り値を示します。
//public ZCNoSQLInsertHelper withReturnValue(NOSQL_RETURN_VALUE returnValue) throws Exception
table.getInsertHelper(<ZCNoSQLItem>).withReturnValue(<NOSQL_RETURN_VALUE>).insert();
許可されるNOSQL_RETURN_VALUEの値は、NEW、OLD、NULLです。
条件と戻り値を指定した挿入
table.getInsertHelper(<ZCNoSQLItem>).withCondition(<ZCNoSQLCondition>).withReturnValue(<NOSQL_RETURN_VALUE>).insert();
最終更新日 2026-02-23 18:09:41 +0530 IST
Yes
No
Send your feedback to us