key property

FilePersistorKey? key
final

The persistence key to use for this collection. The key corresponds to the name of the file that the collection's data and all of the data of its subcollections (that don't specify their own custom key) is stored in.

Ex. Customizing a collection's persistence key:

Loon.collection(
  'users',
  settings: FilePersistorSettings(
    key: FilePersistor.key('custom_users_key'),
  ),
);

Ex. Customizing a document's persistence key:

If documents from the same collection should be distributed to multiple files, then a key builder can be used to vary the persistence key to use at the document-level based on its latest snapshot.

Loon.collection(
  'users',
  settings: FilePersistorSettings(
    key: FilePersistor.keyBuilder((snap) {
      if (snap.data.role == 'admin') {
        return 'admins';
      }
      return 'users';
    }),
  ),
);

Implementation

final FilePersistorKey? key;