SearchableCollectionMixin<TModel extends SearchableDocumentMixin> mixin
Mix-ins to create collections for which search functions are available.
Grant to CollectionBase.
Documents to which SearchableDocumentMixin is granted are eligible.
Specify the target key in searchValueFieldKey in a manner consistent with SearchableDocumentMixin.searchValueFieldKey.
When the search method is executed, it performs a search and stores the search results in its own CollectionBase.
When passing a CollectionModelQuery to CollectionBase, it cannot contain filtering conditions such as isEqualTo
or sorting conditions such as orderBy
.
If they are included, an error occurs and the search cannot be performed.
検索機能を利用できるコレクションを作成するためのミックスイン。
CollectionBaseに付与します。
SearchableDocumentMixinを付与したドキュメントが対象となります。
searchValueFieldKeyで対象となるキーをSearchableDocumentMixin.searchValueFieldKeyと合わせる形で指定します。
searchメソッドを実行すると検索を行ない、検索結果を自身のCollectionBaseに格納します。
CollectionBaseにCollectionModelQueryを渡す場合、isEqualTo
などのフィルタリング条件やorderBy
などのソート条件を含めることができません。
それらが含まれていた場合、エラーとなり検索が行えません。
class SearchableRuntimeMapDocumentModel extends DocumentBase<DynamicMap>
with SearchableDocumentMixin<DynamicMap> {
SearchableRuntimeMapDocumentModel(super.query, super.value);
@override
DynamicMap fromMap(DynamicMap map) {
return ModelFieldValue.fromMap(map);
}
@override
DynamicMap toMap(DynamicMap value) {
return ModelFieldValue.toMap(value);
}
@override
String buildSearchText(DynamicMap value) {
return value.get("name", "") + value.get("text", "");
}
}
class SearchableRuntimeCollectionModel
extends CollectionBase<SearchableRuntimeMapDocumentModel>
with SearchableCollectionMixin<SearchableRuntimeMapDocumentModel> {
SearchableRuntimeCollectionModel(super.query);
@override
SearchableRuntimeMapDocumentModel create([String? id]) {
return SearchableRuntimeMapDocumentModel(
modelQuery.create(id),
{},
);
}
}
void search() {
final query = CollectionModelQuery(
"test",
);
final collection = SearchableRuntimeCollectionModel(query);
collection.search("test");
}
- Superclass constraints
- CollectionBase<
TModel>
- CollectionBase<
Properties
- canNext → bool
-
If the number of elements is limited by ModelQueryFilterType.limit, returns
true
if the next element can be added.no setterinherited - databaseQuery → ModelAdapterCollectionQuery
-
Database queries for collections.
no setterinherited
- first ↔ TModel
-
The first element.
getter/setter pairinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- isEmpty → bool
-
Whether this collection has no elements.
no setterinherited
- isNotEmpty → bool
-
Whether this collection has at least one element.
no setterinherited
-
iterator
→ Iterator<
TModel> -
A new
Iterator
that allows iterating the elements of thisIterable
.no setterinherited - last ↔ TModel
-
The last element.
getter/setter pairinherited
- length ↔ int
-
The number of objects in this list.
getter/setter pairinherited
- loaded → bool
-
Returns
true
if the data was successfully loaded by the load method.no setterinherited -
loading
→ Future<
CollectionBase< ?TModel> > -
If load, reload or next is executed, it waits until the reading process is completed.
no setterinherited
- modelQuery → CollectionModelQuery
-
Query to read and save collections.
no setteroverride
-
reloading
→ Future<
CollectionBase< ?TModel> > -
If reload is done, it waits until the loading process is finished.
no setterinherited
-
reversed
→ Iterable<
TModel> -
An Iterable of the objects in this list in reverse order.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- searchText → String
-
Get the currently searched text.
no setter
- searchValueFieldKey → String
-
The field with this key contains the Bigram data for the search.
no setter
- single → TModel
-
Checks that this iterable has only one element, and returns that element.
no setterinherited
-
subscriptions
→ List<
StreamSubscription> -
List of currently subscribed notifications. All should be canceled when the object is destroyed.
no setterinherited
Methods
-
add(
TModel value) → void -
This operation is not supported by an model collection.
inherited
-
addAll(
Iterable< TModel> iterable) → void -
This operation is not supported by an model collection.
inherited
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
aggregate<
TValue extends AsyncAggregateValue> (ModelAggregateQuery< TValue> query) → TValue -
Get the number of elements in all collections existing in the database.
inherited
-
any(
bool test(TModel element)) → bool -
Checks whether any element of this iterable satisfies
test
.inherited -
asMap(
) → Map< int, TModel> -
An unmodifiable Map view of this list.
inherited
-
batch(
{int splitLength = 100}) → ModelBatchCollectionBuilder< TModel> -
Builder for batch processing.
inherited
-
cast<
E> () → List< E> -
Returns a view of this list as a list of
R
instances.inherited -
clear(
) → void -
This operation is not supported by an model collection.
inherited
-
contains(
Object? element) → bool -
Whether the collection contains an element equal to
element
.inherited -
create(
[String? id]) → TModel -
Create a new document of type
TModel
from the contents of the collection.inherited -
deleteAll(
) → Future< CollectionBase< TModel> > -
Delete all retained documents.
inherited
-
dispose(
) → void -
Discards any resources used by the object. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener will throw after the object is disposed).
inherited
-
elementAt(
int index) → TModel -
Returns the
index
th element.inherited -
every(
bool test(TModel element)) → bool -
Checks whether every element of this iterable satisfies
test
.inherited -
expand<
E> (Iterable< E> f(TModel element)) → Iterable<E> -
Expands each element of this Iterable into zero or more elements.
inherited
-
fillRange(
int start, int end, [TModel? fillValue]) → void -
This operation is not supported by an model collection.
inherited
-
filterOnDidLoad(
List< TModel> value) → Future<List< TModel> > -
Callback called after loading.
inherited
-
firstWhere(
bool test(TModel element), {TModel orElse()?}) → TModel -
The first element that satisfies the given predicate
test
.inherited -
fold<
E> (E initialValue, E combine(E previousValue, TModel element)) → E -
Reduces a collection to a single value by iteratively combining each
element of the collection with an existing value
inherited
-
followedBy(
Iterable< TModel> other) → Iterable<TModel> -
Creates the lazy concatenation of this iterable and
other
.inherited -
forEach(
void f(TModel element)) → void -
Invokes
action
on each element of this iterable in iteration order.inherited -
fromMap(
Map< String, DynamicMap> map, int? limit) → Future<List< TModel> > -
Creates a List<TModel> from a
map
of type Map<String, DynamicMap> decoded from Json.inherited -
getRange(
int start, int end) → Iterable< TModel> -
Creates an Iterable that iterates over a range of elements.
inherited
-
handledOnUpdate(
ModelUpdateNotification update) → Future< void> -
Describe the callback process to pass to ModelAdapterCollectionQuery.callback.
inherited
-
indexOf(
TModel element, [int start = 0]) → int -
The first index of
element
in this list.inherited -
indexWhere(
bool test(TModel element), [int start = 0]) → int -
The first index in the list that satisfies the provided
test
.inherited -
insert(
int index, TModel element) → void -
This operation is not supported by an model collection.
inherited
-
insertAll(
int index, Iterable< TModel> iterable) → void -
This operation is not supported by an model collection.
inherited
-
join(
[String separator = ""]) → String -
Converts each element to a String and concatenates the strings.
inherited
-
lastIndexOf(
TModel element, [int? start]) → int -
The last index of
element
in this list.inherited -
lastIndexWhere(
bool test(TModel element), [int? start]) → int -
The last index in the list that satisfies the provided
test
.inherited -
lastWhere(
bool test(TModel element), {TModel orElse()?}) → TModel -
The last element that satisfies the given predicate
test
.inherited -
load(
) → Future< CollectionBase< TModel> > -
Reads the collection corresponding to modelQuery.
inherited
-
loadRequest(
) → Future< Map< String, DynamicMap> ?> -
Implement internal processing when load, reload, or next is executed.
inherited
-
map<
E> (E f(TModel e)) → Iterable< E> -
The current elements of this iterable modified by
toElement
.inherited -
next(
) → Future< CollectionBase< TModel> > -
If the number of elements is limited by ModelQueryFilterType.limit, additional elements are loaded for the next limited number.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
reduce(
TModel combine(TModel value, TModel element)) → TModel -
Reduces a collection to a single value by iteratively combining elements
of the collection using the provided function.
inherited
-
reload(
) → Future< CollectionBase< TModel> > -
Reload the collection corresponding to modelQuery.
inherited
-
remove(
Object? value) → bool -
This operation is not supported by an model collection.
inherited
-
removeAt(
int index) → TModel -
This operation is not supported by an model collection.
inherited
-
removeLast(
) → TModel -
This operation is not supported by an model collection.
inherited
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
removeRange(
int start, int end) → void -
This operation is not supported by an model collection.
inherited
-
removeWhere(
bool test(TModel element)) → void -
This operation is not supported by an model collection.
inherited
-
replaceQuery(
CollectionModelQuery callback(CollectionModelQuery source)) → Future< CollectionBase< TModel> > -
callback
will redefine a new CollectionModelQuery and execute reload.inherited -
replaceRange(
int start, int end, Iterable< TModel> replacement) → void -
This operation is not supported by an model collection.
inherited
-
retainWhere(
bool test(TModel element)) → void -
This operation is not supported by an model collection.
inherited
-
search(
String searchText) → Future< CollectionBase< TModel> > -
Search within a collection with
searchText
. -
setAll(
int index, Iterable< TModel> iterable) → void -
This operation is not supported by an model collection.
inherited
-
setRange(
int start, int end, Iterable< TModel> iterable, [int skipCount = 0]) → void -
This operation is not supported by an model collection.
inherited
-
shuffle(
[Random? random]) → void -
This operation is not supported by an model collection.
inherited
-
singleWhere(
bool test(TModel element), {TModel orElse()?}) → TModel -
The single element that satisfies
test
.inherited -
skip(
int n) → Iterable< TModel> -
Creates an Iterable that provides all but the first
count
elements.inherited -
skipWhile(
bool test(TModel value)) → Iterable< TModel> -
Creates an
Iterable
that skips leading elements whiletest
is satisfied.inherited -
sort(
[int compare(TModel a, TModel b)?]) → void -
This operation is not supported by an model collection.
inherited
-
sublist(
int start, [int? end]) → List< TModel> -
Returns a new list containing the elements between
start
andend
.inherited -
take(
int n) → Iterable< TModel> -
Creates a lazy iterable of the
count
first elements of this iterable.inherited -
takeWhile(
bool test(TModel value)) → Iterable< TModel> -
Creates a lazy iterable of the leading elements satisfying
test
.inherited -
toList(
{bool growable = true}) → List< TModel> -
Creates a List containing the elements of this Iterable.
inherited
-
toSet(
) → Set< TModel> -
Creates a Set containing the same elements as this iterable.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
transaction(
) → ModelTransactionCollectionBuilder< TModel> -
Builder for transactions.
inherited
-
where(
bool test(TModel element)) → Iterable< TModel> -
Creates a new lazy Iterable with all elements that satisfy the
predicate
test
.inherited -
whereType<
E> () → Iterable< E> -
Creates a new lazy Iterable with all elements that have type
T
.inherited
Operators
-
operator +(
List< TModel> other) → List<TModel> -
Returns the concatenation of this list and
other
.inherited -
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
int index) → TModel -
The object at the given
index
in the list.inherited -
operator []=(
int index, TModel value) → void -
This operation is not supported by an model collection.
inherited
Constants
- defaultSearchValueFieldKey → const String
- Field key for default search.