検索条件

BaaS@rakuza SDKでは複数レコード取得時に検索条件を指定する事ができます。

例えば、以下は一致検索条件と中間一致検索条件を指定してオブジェクトデータを検索する例です。複数条件を指定した場合はAND条件になります。

let objectId = "shop"

let searchConditions = [
    RKZSearchCondition(RKZSearchConditionEqual, searchColumn: "category_cd", searchValueArray: ["0001"]), // 一致検索条件
    RKZSearchCondition(RKZSearchConditionLikeBoth, searchColumn: "name", searchValueArray: ["パン"]) // 中間一致検索条件
]

RKZService.sharedInstance().getDataList(objectId, searchConditionArray: searchConditions, sortConditionArray: nil) { dataList, responseStatus in
    // ...
}
NSString *objectId = @"shop";

NSArray<RKZSearchCondition *> *searchConditions = @[
    [[RKZSearchCondition alloc] initWithSearchConditionType:RKZSearchConditionEqual searchColumn:@"category_cd" searchValueArray:@[@"0001"]], // 一致検索条件
    [[RKZSearchCondition alloc] initWithSearchConditionType:RKZSearchConditionLikeBoth searchColumn:@"name" searchValueArray:@[@"パン"]], // 中間一致検索条件
];

[[RKZService sharedInstance] getDataList:objectId searchConditionArray:searchConditions sortConditionArray:nil withBlock:^(NSArray<RKZObjectData *> * _Nonnull dataList, RKZResponseStatus * _Nonnull responseStatus) {
    // ...
}];
val objectId = "shop"

val searchConditions = listOf(
    RKZSearchCondition(RKZSearchCondition.EQUAL, "category_cd", listOf("0001")), // 一致検索条件
    RKZSearchCondition(RKZSearchCondition.LIKE_BOTH, "name", listOf("パン")) // 中間一致検索条件
)

RKZClient.getInstance().getDataList(objectId, searchConditions, null) { dataList, rkzResponseStatus ->
    // ...
}
String objectId = "shop";

List<RKZSearchCondition> searchConditions = Arrays.asList(
    new RKZSearchCondition(RKZSearchCondition.EQUAL, "category_cd", Arrays.asList("0001")), // 一致検索条件
    new RKZSearchCondition(RKZSearchCondition.LIKE_BOTH, "name", Arrays.asList("パン")) // 中間一致検索条件
);

RKZClient.getInstance().getDataList(objectId, searchConditions, null, new OnGetRKZObjectDataListListener() {
    @Override
    public void onGetRKZObjectDataList(List<RKZObjectData> dataList, RKZResponseStatus rkzResponseStatus) {
        // ...
    }
});
var objectId = 'shop'

var searchConditions = [
  RKZSearchCondition.equal('category_cd', '0001'), // 一致検索条件
  RKZSearchCondition.likeBoth('name', 'パン') // 中間一致検索条件
]

RKZClient.getDataList(objectId, searchConditions, null, function(dataList) {
  // ...
}, function(error) {
  // ...
})
const dataResult = await RKZ.Data.query('shop')
    .equalTo('category_cd', '0001') // 一致検索条件
    .contains('name', 'パン') // 中間一致検索条件
    .find()
final query = RKZClient.instance.dataQuery('shop')
  ..equalTo('category_cd', '0001') // 一致検索条件
  ..contains('name', 'パン'); // 中間一致検索条件
final dataResult = await query.find();
const dataResult = await RKZ.Data.query('shop')
    .equalTo('category_cd', '0001') // 一致検索条件
    .contains('name', 'パン') // 中間一致検索条件
    .find()
curl --location '<配布したベースURL>/api_zeus/masters/ex/get/shop' \
--header 'Authorization: Bearer <配布したサーバー認証トークン>' \
--form 'tenant_id="<配布したテナントID>"' \
--form 'contents[search_condition][category_cd]="0001"' \
--form 'contents[search_condition][name]="パン∀like_both"'

ヒント

JavaScript・Flutter・Node.jsではクエリオブジェクトに対してメソッドチェーンで各検索条件を指定します。

注意

検索条件値にNULL値や空文字列を指定した場合、条件は無視されます。


指定可能な検索条件は以下です。

一致検索条件

検索値に一致するレコードに絞り込みます。

RKZSearchCondition(RKZSearchConditionEqual, searchColumn: "name", searchValueArray: ["People Cafe Kurashiki"])
[[RKZSearchCondition alloc] initWithSearchConditionType:RKZSearchConditionEqual searchColumn:@"name" searchValueArray:@[@"People Cafe Kurashiki"]];
RKZSearchCondition(RKZSearchCondition.EQUAL, "name", listOf("People Cafe Kurashiki"))
new RKZSearchCondition(RKZSearchCondition.EQUAL, "name", Arrays.asList("People Cafe Kurashiki"));
RKZSearchCondition.equal('name', 'People Cafe Kurashiki')
query.equalTo('name', 'People Cafe Kurashiki')
query.equalTo('name', 'People Cafe Kurashiki');
query.equalTo('name', 'People Cafe Kurashiki')
--form 'contents[search_condition][name]="People Cafe Kurashiki"'

不一致検索条件

検索値に一致しないレコードに絞り込みます。

RKZSearchCondition(RKZSearchConditionNotEqual, searchColumn: "name", searchValueArray: ["People Cafe Kurashiki"])
[[RKZSearchCondition alloc] initWithSearchConditionType:RKZSearchConditionNotEqual searchColumn:@"name" searchValueArray:@[@"People Cafe Kurashiki"]];
RKZSearchCondition(RKZSearchCondition.NOT_EQUAL, "name", listOf("People Cafe Kurashiki"))
new RKZSearchCondition(RKZSearchCondition.NOT_EQUAL, "name", Arrays.asList("People Cafe Kurashiki"));
RKZSearchCondition.notEqual('name', 'People Cafe Kurashiki')
query.notEqualTo('name', 'People Cafe Kurashiki')
query.notEqualTo('name', 'People Cafe Kurashiki');
query.notEqualTo('name', 'People Cafe Kurashiki')
--form 'contents[search_condition][name]="People Cafe Kurashiki∀not_equal"'

要素リスト一致検索条件

検索値(複数件)の何れかが含まれるレコードに絞り込みます。

RKZSearchCondition(RKZSearchConditionIn, searchColumn: "prefecture", searchValueArray: ["0033", "0034"])
[[RKZSearchCondition alloc] initWithSearchConditionType:RKZSearchConditionIn searchColumn:@"prefecture" searchValueArray:@[@"0033", @"0034"]];
RKZSearchCondition(RKZSearchCondition.IN, "prefecture", listOf("0033", "0034"))
new RKZSearchCondition(RKZSearchCondition.IN, "prefecture", Arrays.asList("0033", "0034"));
RKZSearchCondition.in('prefecture', ['0033', '0034'])
query.in('prefecture', ['0033', '0034'])
query.containedIn('prefecture', ['0033', '0034']);
query.in('prefecture', ['0033', '0034'])
--form 'contents[search_condition][prefecture]="0033,0034∀in"'

要素リスト不一致検索条件

検索値(複数件)の何れも含まれないレコードに絞り込みます。

RKZSearchCondition(RKZSearchConditionNotIn, searchColumn: "prefecture", searchValueArray: ["0033", "0034"])
[[RKZSearchCondition alloc] initWithSearchConditionType:RKZSearchConditionNotIn searchColumn:@"prefecture" searchValueArray:@[@"0033", @"0034"]];
RKZSearchCondition(RKZSearchCondition.NOT_IN, "prefecture", listOf("0033", "0034"))
new RKZSearchCondition(RKZSearchCondition.NOT_IN, "prefecture", Arrays.asList("0033", "0034"));
RKZSearchCondition.notIn('prefecture', ['0033', '0034'])
query.notIn('prefecture', ['0033', '0034'])
query.notContainedIn('prefecture', ['0033', '0034']);
query.notIn('prefecture', ['0033', '0034'])
--form 'contents[search_condition][prefecture]="0033,0034∀not_in"'

範囲検索条件(検索値含む)

検索値(範囲)に含まれるレコードに絞り込みます。

この条件は検索値に一致するレコードも取得対象になります。 例えば、以下の例だとevent_date2021-10-01または2021-10-31の場合、取得されます。

RKZSearchCondition(RKZSearchConditionBetweenInclude, searchColumn: "event_date", searchValueArray: ["2021-10-01", "2021-10-31"])
[[RKZSearchCondition alloc] initWithSearchConditionType:RKZSearchConditionBetweenInclude searchColumn:@"event_date" searchValueArray:@[@"2021-10-01", @"2021-10-31"]];
RKZSearchCondition(RKZSearchCondition.BETWEEN_INCLUDE, "event_date", listOf("2021-10-01", "2021-10-31"))
new RKZSearchCondition(RKZSearchCondition.BETWEEN_INCLUDE, "event_date", Arrays.asList("2021-10-01", "2021-10-31"));
RKZSearchCondition.betweenInclude('event_date', ['2021-10-01', '2021-10-31'])
query.betweenInclude('event_date', '2021-10-01', '2021-10-31')
query.betweenInclude('event_date', '2021-10-01', '2021-10-31');
query.betweenInclude('event_date', '2021-10-01', '2021-10-31')
--form 'contents[search_condition][event_date]="2021-10-01,2021-10-31∀between_include"'

範囲検索条件(検索値含まない)

検索値(範囲)に含まれるレコードに絞り込みます。

この条件は検索値に一致するレコードは取得対象になりません。 例えば、以下の例だとevent_date2021-10-01または2021-10-31の場合、取得されません。

RKZSearchCondition(RKZSearchConditionBetweenExclude, searchColumn: "event_date", searchValueArray: ["2021-10-01", "2021-10-31"])
[[RKZSearchCondition alloc] initWithSearchConditionType:RKZSearchConditionBetweenExclude searchColumn:@"event_date" searchValueArray:@[@"2021-10-01", @"2021-10-31"]];
RKZSearchCondition(RKZSearchCondition.BETWEEN_EXCLUDE, "event_date", listOf("2021-10-01", "2021-10-31"))
new RKZSearchCondition(RKZSearchCondition.BETWEEN_EXCLUDE, "event_date", Arrays.asList("2021-10-01", "2021-1new 0-31"));
RKZSearchCondition.betweenExclude('event_date', ['2021-10-01', '2021-10-31'])
query.betweenExclude('event_date', '2021-10-01', '2021-10-31')
query.betweenExclude('event_date', '2021-10-01', '2021-10-31');
query.betweenExclude('event_date', '2021-10-01', '2021-10-31')
--form 'contents[search_condition][event_date]="2021-10-01,2021-10-31∀between_exclude"'

検索値以下の検索条件

検索値以下のレコードに絞り込みます。

RKZSearchCondition(RKZSearchConditionLessThanInclude, searchColumn: "event_date", searchValueArray: ["2021-09-30"])
[[RKZSearchCondition alloc] initWithSearchConditionType:RKZSearchConditionLessThanInclude searchColumn:@"event_date" searchValueArray:@[@"2021-09-30"]];
RKZSearchCondition(RKZSearchCondition.LESS_THAN_INCLUDE, "event_date", listOf("2021-09-30"))
new RKZSearchCondition(RKZSearchCondition.LESS_THAN_INCLUDE, "event_date", Arrays.asList("2021-09-30"));
RKZSearchCondition.lessThanInclude('event_date', '2021-09-30')
query.lessThanOrEqualTo('event_date', '2021-09-30')
query.lessThanOrEqualTo('event_date', '2021-09-30');
query.lessThanOrEqualTo('event_date', '2021-09-30')
--form 'contents[search_condition][event_date]="2021-09-30∀less_than_include"'

検索値以上の検索条件

検索値以上のレコードに絞り込みます。

RKZSearchCondition(RKZSearchConditionGreaterThanInclude, searchColumn: "event_date", searchValueArray: ["2021-10-01"])
[[RKZSearchCondition alloc] initWithSearchConditionType:RKZSearchConditionGreaterThanInclude searchColumn:@"event_date" searchValueArray:@[@"2021-10-01"]];
RKZSearchCondition(RKZSearchCondition.GREATER_THAN_INCLUDE, "event_date", listOf("2021-10-01"))
new RKZSearchCondition(RKZSearchCondition.GREATER_THAN_INCLUDE, "event_date", Arrays.asList("2021-10-01"));
RKZSearchCondition.greaterThanInclude('event_date', '2021-10-01')
query.greaterThanOrEqualTo('event_date', '2021-10-01')
query.greaterThanOrEqualTo('event_date', '2021-10-01');
query.greaterThanOrEqualTo('event_date', '2021-10-01')
--form 'contents[search_condition][event_date]="2021-10-01∀greater_than_include"'

前方一致検索条件

検索値に前方一致するレコードに絞り込みます。

RKZSearchCondition(RKZSearchConditionLikeBefore, searchColumn: "name", searchValueArray: ["People"])
[[RKZSearchCondition alloc] initWithSearchConditionType:RKZSearchConditionLikeBefore searchColumn:@"name" searchValueArray:@[@"People"]];
RKZSearchCondition(RKZSearchCondition.LIKE_BEFORE, "name", listOf("People"))
new RKZSearchCondition(RKZSearchCondition.LIKE_BEFORE, "name", Arrays.asList("People"));
RKZSearchCondition.likeBefore('name', 'People')
query.startsWith('name', 'People')
query.startsWith('name', 'People');
query.startsWith('name', 'People')
--form 'contents[search_condition][name]="People∀like_before"'

後方一致検索条件

検索値に後方一致するレコードに絞り込みます。

RKZSearchCondition(RKZSearchConditionLikeAfter, searchColumn: "name", searchValueArray: ["Kurashiki"])
[[RKZSearchCondition alloc] initWithSearchConditionType:RKZSearchConditionLikeAfter searchColumn:@"name" searchValueArray:@[@"Kurashiki"]];
RKZSearchCondition(RKZSearchCondition.LIKE_AFTER, "name", listOf("Kurashiki"))
new RKZSearchCondition(RKZSearchCondition.LIKE_AFTER, "name", Arrays.asList("Kurashiki"));
RKZSearchCondition.likeAfter('name', 'Kurashiki')
query.endsWith('name', 'Kurashiki')
query.endsWith('name', 'Kurashiki');
query.endsWith('name', 'Kurashiki')
--form 'contents[search_condition][name]="Kurashiki∀like_after"'

部分一致検索条件

検索値に部分一致するレコードに絞り込みます。

RKZSearchCondition(RKZSearchConditionLikeBoth, searchColumn: "name", searchValueArray: ["Cafe"])
[[RKZSearchCondition alloc] initWithSearchConditionType:RKZSearchConditionLikeBoth searchColumn:@"name" searchValueArray:@[@"Cafe"]];
RKZSearchCondition(RKZSearchCondition.LIKE_BOTH, "name", listOf("Cafe"))
new RKZSearchCondition(RKZSearchCondition.LIKE_BOTH, "name", Arrays.asList("Cafe"));
RKZSearchCondition.likeBoth('name', 'Cafe')
query.contains('name', 'Cafe')
query.contains('name', 'Cafe');
query.contains('name', 'Cafe')
--form 'contents[search_condition][name]="Cafe∀like_both"'

チェックボックス項目の要素リスト一致検索条件

チェックボックス項目に対して、検索値(複数件)の何れかが含まれるレコードに絞り込みます。

RKZSearchCondition(RKZSearchConditionLikeOr, searchColumn: "tags", searchValueArray: ["0001", "0002"])
[[RKZSearchCondition alloc] initWithSearchConditionType:RKZSearchConditionLikeOr searchColumn:@"tags" searchValueArray:@[@"0001", @"0002"]];
RKZSearchCondition(RKZSearchCondition.LIKE_OR, "tags", listOf("0001", "0002"))
new RKZSearchCondition(RKZSearchCondition.LIKE_OR, "tags", Arrays.asList("0001", "0002"));
RKZSearchCondition.likeOr('tags', ['0001', '0002'])
query.containsInArray('tags', ['0001', '0002'])
query.containsInArray('tags', ['0001', '0002']);
query.containsInArray('tags', ['0001', '0002'])
--form 'contents[search_condition][tags]="0001,0002∀like_or"'