BelongsTo<E extends DataModelMixin<E>> class

A Relationship that models a to-one ownership.

Example: A book that belongs to an author

class Book with DataModel<Book> {
 @override
 final int id;
 final String title;
 final BelongsTo<Author> author;

 Todo({this.id, this.title, this.author});
}
Inheritance

Constructors

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

Properties

db → Database
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
inverseName String?
no setterinherited
isPresent bool
Whether the relationship has a value.
no setterinherited
key String?
Returns the value's key.
no setter
keys Set<String>
Returns keys in this relationship.
no setterinherited
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
value ↔ E?
Obtains the single E value of this relationship (null if not present).
getter/setter pair

Methods

adjacentRelationships<R extends DataModelMixin<R>>() Iterable<Relationship<DataModelMixin, dynamic>>
inherited
initialize({required String ownerKey, required String name, String? inverseName}) Relationship<E, E?>
Initializes this relationship (typically when initializing the owner in DataModelMixin) by supplying the owner, and related metadata.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() → dynamic
This is used to make json_serializable's explicitToJson transparent.
inherited
toString() String
A string representation of this object.
override
watch() DelayedStateNotifier<E?>
Returns a StateNotifier which emits the latest value of this BelongsTo relationship.
override

Operators

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