-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dart3a' into dart3a
- Loading branch information
Showing
3 changed files
with
71 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import 'package:tekartik_app_cv_firestore/app_cv_firestore.dart'; | ||
import 'package:tekartik_firebase_firestore/utils/json_utils.dart'; | ||
|
||
/// info json list to document list | ||
T infoJsonToDocument<T extends CvFirestoreDocument>(Model infoJson) { | ||
var docInfo = FirestoreDocumentInfo.fromJsonMap(infoJson); | ||
var doc = docInfo.data.asMap().cv<T>()..path = docInfo.path; | ||
return doc; | ||
} | ||
|
||
/// info json list to document list | ||
List<T> infoJsonListToDocumentList<T extends CvFirestoreDocument>( | ||
List<Model> infoJsonList) { | ||
return infoJsonList | ||
.map((infoJson) => infoJsonToDocument<T>(infoJson)) | ||
.toList(); | ||
} | ||
|
||
/// Helpers | ||
extension TekartikCvFirestoreDocumentSnapshotListInfoJsonListExt | ||
on List<DocumentSnapshot> { | ||
List<Model> toInfoJsonList() { | ||
return map((snapshot) => | ||
FirestoreDocumentInfo.fromDocumentSnapshot(snapshot).toJsonMap()) | ||
.toList(); | ||
} | ||
} | ||
|
||
/// Helpers | ||
extension TekartikCvFirestoreCvDocumentInfoJsonExt on CvFirestoreDocument { | ||
Model toInfoJson() { | ||
return FirestoreDocumentInfo(path: ref.path, data: DocumentData(toMap())) | ||
.toJsonMap(); | ||
} | ||
} | ||
|
||
/// Helpers | ||
extension TekartikCvFirestoreCvDocumentListInfoJsonListExt | ||
on List<CvFirestoreDocument> { | ||
List<Model> toInfoJsonList() { | ||
return map((document) => document.toInfoJson()).toList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters