CocobaseModel<T> class abstract

Base class for auto-convertible models

Implement this to enable automatic conversion with listDocuments

Example:

class Book extends CocobaseModel<Book> {
  final String title;
  final String content;

  Book({required this.title, required this.content});

  @override
  factory Book.fromJson(Map<String, dynamic> json) {
    return Book(
      title: json['title'],
      content: json['content'],
    );
  }
}

// Now you can use it without specifying converter:
final books = await db.listDocuments<Book>("books");

Constructors

CocobaseModel()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

fromJson<T>(Map<String, dynamic> json) → T
Factory constructor that subclasses must implement