HasMany<E extends DataModelMixin<E>> class

A Relationship that models a to-many ownership.

Example: An author who has many books

class Author with DataModel<Author> {
 @override
 final int id;
 final String name;
 final HasMany<Book> books;

 Todo({this.id, this.name, this.books});
}
Inheritance

Constructors

HasMany([Set<E>? models])
Creates a HasMany relationship, with an optional initial Set<E>.
HasMany.fromJson(Map<String, dynamic> map)
For internal use with json_serializable.
factory
HasMany.remove()

Properties

db → Database
no setterinherited
first → E
no setter
hashCode int
The hash code for this object.
no setterinherited
inverseName String?
no setterinherited
isEmpty bool
no setter
isNotEmpty bool
no setter
isPresent bool
Whether the relationship has a value.
no setterinherited
keys Set<String>
Returns keys in this relationship.
no setteroverride
length int
no setterinherited
name String
no setterinherited
owner DataModelMixin<DataModelMixin>?
no setterinherited
ownerKey String
no setterinherited
props List<Object?>
The list of properties that will be used to determine whether two instances are equal.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stringify bool?
If set to true, the toString method will be overridden to output this instance's props.
no setterinherited

Methods

add(E value) bool
Add a value to this Relationship
addAll(Iterable<E> values) → void
adjacentRelationships<R extends DataModelMixin<R>>() Iterable<Relationship<DataModelMixin, dynamic>>
inherited
contains(E element) bool
initialize({required String ownerKey, required String name, String? inverseName}) Relationship<E, Set<E>>
Initializes this relationship (typically when initializing the owner in DataModelMixin) by supplying the owner, and related metadata.
inherited
map<T>(T f(E)) Iterable<T>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
remove(E value) bool
Removes a value from this Relationship
toJson() → dynamic
This is used to make json_serializable's explicitToJson transparent.
inherited
toList() List<E>
toSet() Set<E>
toString() String
A string representation of this object.
override
watch() DelayedStateNotifier<Set<E>>
Returns a StateNotifier which emits the latest Set<E> representing this HasMany relationship.
override
where(bool test(E)) Iterable<E>

Operators

operator ==(Object other) bool
The equality operator.
inherited