Collection class

A set of documents in a database (Database).

In relational databases, "collection" means a table.

An example:

Future<void> main() async {
  // Use an in-memory database
  final database = MemoryDatabaseAdapter().database();

  // Our collection
  final collection = database.collection('pizzas');

  // Our document
  final document = collection.newDocument();

  await document.insert({
    'name': 'Pizza Margherita',
    'rating': 3.5,
    'ingredients': ['dough', 'tomatoes'],
    'similar': [
      database.collection('recipes').document('pizza_funghi'),
    ],
  });
  print('Successfully inserted pizza.');

  await document.patch({
    'rating': 4.5,
  });
  print('Successfully patched pizza.');

  await document.delete();
  print('Successfully deleted pizza.');
}

Constructors

Collection(Database database, String collectionId, {Document parentDocument, Serializers serializers, FullType fullType})
Constructs a collection. [...]

Properties

collectionId String
A non-blank identifier. [...]
final
database Database
Returns database where the document is.
final
fullType FullType
final
hashCode int
The hash code for this object. [...]
read-only, override
parentDocument Document
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
serializers Serializers
final

Methods

column<T>(String name) Column<T>
Returns a column.
document(String documentId) Document
Returns a document. [...]
insert({Map<String, Object> data, Reach reach}) Future<Document>
Inserts a new value.
newDocument() Document
Returns a new document with a random identifier. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
schema() Future<Schema>
Reads schema of this collection, which may be null.
Searches documents. [...]
searchAndDelete({Query query, Reach reach}) Future<void>
Deletes all documents that match the filter. [...]
searchChunked({Query query, Reach reach: Reach.server}) Stream<QueryResult>
Searches documents and returns the snapshots in chunks, which means that the snapshots don't have to be kept to the memory at the same time. [...]
searchIncrementally({Query query, Reach reach: Reach.server}) Stream<QueryResult>
Searches documents and returns the result as a stream where the snapshot list incrementally grows larger. [...]
toString() String
Returns a string representation of this object.
override

Operators

operator ==(dynamic other) bool
The equality operator. [...]
override