sumibi 1.0.0 copy "sumibi: ^1.0.0" to clipboard
sumibi: ^1.0.0 copied to clipboard

Sumibi is simple, hookable Firestore library. You can inject hook methods on `setData`/`set` and `updateData`/`update`.

Sumibi #

sumibi_logo

Sumibi is thin could_firestore wrapper.

Sumibi can inject your own hooks on calling of setData/set and updateData/update.

Usage #

final sumibi = SumibiFirestore(
  Firestore.instance,
  onSetDataHook: (String documentPath, Map<String, dynamic> data) {
    data["createdAt"] = FieldValue.serverTimestamp();
    data["updatedAt"] = FieldValue.serverTimestamp();
  },
  onUpdateDataHook: (String documentPath, Map<String, dynamic> data) {
    data["updatedAt"] = FieldValue.serverTimestamp();
  },
);


// Now `user` have properties `name`, `createdAt` and `updatedAt`.
final user = await sumibi.collection("/users").add({"name": "John"});

// Now `user.name` will be "May" and `user.updatedAt` will be updated. 
await user.updateData({"name": "May"});



final friends = user.collection("/friends");
await sumibi.batch()
  // Also `createdAt` and `updatedAt` will be created.
  ..setData(friends.document("/a"), {"name": "Alex"})
  ..setData(friends.document("/b"), {"name": "Bob"})
  // `user.updatedAt` will be updated.
  ..updateData(user, {"numOfFriends": 2})
  ..commit();



sumibi.runTransaction((transaction) {
  // After this transaction, `user.updatedAt` will be updated.
  transaction.update(user, {"likeCount": FieldValue.increment(1)});
});

SumibiFirestore implements Firestore class of could_firestore. So you can use the instance of SumibiFirestore as Firestore.

0
likes
20
points
20
downloads

Publisher

unverified uploader

Weekly Downloads

Sumibi is simple, hookable Firestore library. You can inject hook methods on `setData`/`set` and `updateData`/`update`.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

cloud_firestore, firebase_core, flutter

More

Packages that depend on sumibi