Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kikuchy/sumibi
Simple hookable Firestore library 🔥
https://github.com/kikuchy/sumibi
dart firebase firestore flutter
Last synced: 1 day ago
JSON representation
Simple hookable Firestore library 🔥
- Host: GitHub
- URL: https://github.com/kikuchy/sumibi
- Owner: kikuchy
- License: other
- Created: 2020-05-16T12:48:28.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-05-16T13:25:21.000Z (over 4 years ago)
- Last Synced: 2024-12-20T05:03:01.442Z (6 days ago)
- Topics: dart, firebase, firestore, flutter
- Language: Dart
- Homepage: https://pub.dev/packages/sumibi
- Size: 104 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Sumibi
![sumibi_logo](./art/logo.jpg)
**Sumibi** is thin [could_firestore](https://pub.dev/packages/cloud_firestore) wrapper.
Sumibi can inject your own hooks on calling of `setData`/`set` and `updateData`/`update`.
## Usage
```dart
final sumibi = SumibiFirestore(
Firestore.instance,
onSetDataHook: (String documentPath, Map data) {
data["createdAt"] = FieldValue.serverTimestamp();
data["updatedAt"] = FieldValue.serverTimestamp();
},
onUpdateDataHook: (String documentPath, Map 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`](https://pub.dev/documentation/cloud_firestore/latest/cloud_firestore/Firestore-class.html)
class of [could_firestore](https://pub.dev/packages/cloud_firestore).
So you can use the instance of `SumibiFirestore` as `Firestore`.