Document<T> class

A document in a Collection.

In relational databases, "document" means a row.

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': [
  print('Successfully inserted pizza.');

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

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


Document(Collection parent, String documentId)
Constructs a document. Usually you should call the method collection.document("id") instead of this constructor.


database Database
Returns database where the document is.
documentId String
A non-blank document identifier.
hashCode int
The hash code for this object.
read-only, override
parent Collection
Collection where the document is.
parentDatabase Database
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


delete({Reach reach, bool mustExist = false}) Future<void>
Deletes the document.
exists({Reach reach = Reach.regional}) Future<bool>
Tells whether the document exists.
get({Schema schema, Reach reach}) Future<Snapshot>
Returns the current snapshot.
getIncrementally({Schema schema, Reach reach}) Stream<Snapshot>
Returns an incrementally improving stream snapshots until the best available snapshot has been received.
insert({Map<String, Object> data, Reach reach = Reach.regional}) Future<void>
Inserts the document.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
patch({Map<String, Object> data, Reach reach}) Future<void>
Patches the document.
toString() String
A string representation of this object.
update({Map<String, Object> data, Reach reach = Reach.regional}) Future<void>
Updates the document.
upsert({Map<String, Object> data, Reach reach}) Future<void>
Upserts ("inserts or updates") the document.
watch({Schema schema, Duration interval, Reach reach}) Stream<Snapshot>
Returns am infinite stream of snapshots.


operator ==(dynamic other) bool
The equality operator.