data_layer_firestore 0.0.2 copy "data_layer_firestore: ^0.0.2" to clipboard
data_layer_firestore: ^0.0.2 copied to clipboard

Provides Firestore-specific bindings for pkg:data_layer.

pub package

Data Layer Firestore #

An add-on to pkg:data_layer which provides a Firestore implementation of the Source interface.

Motivation #

Seamlessly plug Cloud Firestore into your Flutter apps' data_layer repositories with the FirestoreSource class from this package.

Index #

Architecture #

pkg:data_layer_firestore provides a FirestoreSource class which implements the WatchableSource interface to seamlessly integrate Cloud Firestore into your data_layer ecosystem. This source handles all necessary translation between data_layer's request details and Firestore's querying syntax, while also supporting real-time data streaming.

Getting started #

Add the following to your pubspec.yaml:

dependencies:
  data_layer: ^0.0.7
  data_layer_firestore: ^0.0.2

Creating a FirestoreSource #

Instances of a FirestoreSource are meant to be used within the context of a SourceList.

SourceList(
  ...
  sources: [
    LocalMemorySource(bindings: User.bindings),
    FirestoreSource(
      FirebaseFirestore.instance,
      bindings: User.bindings,
      collectionName: 'users',
    ),
  ],
)

Server Timestamp Fields #

FirestoreSource can automatically populate server timestamps on document creation and update operations:

FirestoreSource(
  FirebaseFirestore.instance,
  bindings: User.bindings,
  collectionName: 'users',
  onCreateServerTimestampFields: ['createdAt'],
  onUpdateServerTimestampFields: ['updatedAt'],
)

Untyped Merges (raw) #

To merge an arbitrary Map<String, dynamic> into a document without deserializing into a full object model:

await firestoreSource.raw('user_123', {
  'lastActive': DateTime.now(),
  'status': 'online',
});
0
likes
0
points
171
downloads

Publisher

unverified uploader

Weekly Downloads

Provides Firestore-specific bindings for pkg:data_layer.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

cloud_firestore, data_layer, firebase_core, flutter, logging, stream_transform

More

Packages that depend on data_layer_firestore