-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a49f7db
commit 4ec39db
Showing
5 changed files
with
181 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// | ||
// CBLArrayIndexConfiguration.h | ||
// CouchbaseLite | ||
// | ||
// Copyright (c) 2024 Couchbase, Inc All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <CouchbaseLite/CBLIndexConfiguration.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/** | ||
Configuration for indexing property values within nested arrays in documents, | ||
intended for use with the UNNEST query. | ||
*/ | ||
|
||
@interface CBLArrayIndexConfiguration : CBLIndexConfiguration | ||
|
||
/** | ||
Path to the array, which can be nested. | ||
*/ | ||
|
||
@property (nonatomic, readonly) NSString* path; | ||
|
||
/** | ||
The expressions representing the values within the array to be indexed. | ||
*/ | ||
|
||
@property (nonatomic, readonly, nullable) NSArray<NSString*>* expressions; | ||
|
||
/** | ||
Initializes the configuration with paths to the nested array | ||
and the optional expressions for the values within the arrays to be indexed. | ||
@param path Path to the array, which can be nested to be indexed. | ||
@note Use "[]" to represent a property that is an array of each nested | ||
array level. For a single array or the last level array, the "[]" is optional. | ||
For instance, use "contacts[].phones" to specify an array of phones within | ||
each contact. | ||
@param expressions An optional array of strings, where each string | ||
represents an expression defining the values within the array | ||
to be indexed. If the array specified by the path contains | ||
scalar values, this parameter can be null. | ||
@return The CBLArrayIndexConfiguration object. | ||
*/ | ||
|
||
- (instancetype) initWithPath: (NSString*)path | ||
expressions: (nullable NSArray<NSString*>*)expressions; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// CBLArrayIndexConfiguration.m | ||
// CouchbaseLite | ||
// | ||
// Copyright (c) 2024 Couchbase, Inc All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
#import "CBLArrayIndexConfiguration.h" | ||
#import "CBLIndexConfiguration+Internal.h" | ||
|
||
@implementation CBLArrayIndexConfiguration | ||
|
||
@synthesize path=_path, expressions=_expressions; | ||
|
||
- (instancetype) initWithPath: (NSString*) path | ||
expressions: (nullable NSArray<NSString*>*)expressions { | ||
|
||
if(expressions){ | ||
for (NSString* expression in expressions) { | ||
if (!expression) { | ||
[NSException raise: NSInvalidArgumentException format: @"Expressions can't contain nil"]; | ||
} | ||
} | ||
} | ||
|
||
self = [super initWithIndexType: kC4ArrayIndex | ||
expressions: expressions]; | ||
if (self) { | ||
_path = path; | ||
_expressions = expressions; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
- (instancetype) initWithPath: (NSString*)path { | ||
self = [self initWithPath: path expressions: nil]; | ||
return self; | ||
} | ||
|
||
- (C4IndexOptions) indexOptions { | ||
C4IndexOptions c4options = { }; | ||
//c4options.unnestPath = _path; | ||
return c4options; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters