Migration to cloud firestore 2.0.0 #6028
Unanswered
Patrick386
asked this question in
Q&A
Replies: 4 comments
-
cc @rrousselGit |
Beta Was this translation helpful? Give feedback.
0 replies
-
What does "throws an error" means? What is the error? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi,
I haven't seen enough of the documentation.
I've found a problem with my code.
I'll try again and tell you if the problem persists.
Thank you.
/Patrick
2021년 5월 5일 (수) 오후 9:04, Remi Rousselet ***@***.***>님이 작성:
… What does "throws an error" means?
What is the error?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#6028 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AL3TF7IAMGESY3KQIGW3DDLTMEX3FANCNFSM44EFXRFQ>
.
--
SINT Patrick
대표이사 공병주
Back Office
19, Wiryegwangjang-ro, Sujeong-gu, Seongnam-si, Gyeonggi-do, Republic of
Korea
Tel +82 02 400 8465 Mobile +82 010 5386 8880
Email ***@***.*** ***@***.***>
CONFIDENTIAL: The information contained in this e-mail transmission is
legally privileged and confidential. It may also be protected by law as
attorney work product and attorney-client privileged communication. It is
intended solely for the recipient(s) identified above. If you have received
this e-mail transmission in error or you are not the intended recipient,
please contact the sender immediately and destroy the transmission. Any
distribution, reproduction, or dissemination of the message in this e-mail
transmission is prohibited. Thank you for your cooperation in advance.
127, Beobwon-ro, Songpa-gu, Seoul, Republic of Korea (05836)
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi,
I brought the model list using Reverpod> stream provider.
However, I am not sure what to do when migrating.
I tried, but couldn't get the desired value. (<List<ProductSlpModel>>)
What is the method?
OLD CODE:
final productSlpStreamProvider =
AutoDisposeStreamProvider<List<ProductSlpModel>>((ref) {
final Stream<QuerySnapshot> snapshot = productSlpCollectionRef
.orderBy(CREATED_AT)
.snapshots();
return snapshot.map((snapshot) => snapshot.docs
.map((document) => ProductSlpModel.formJson(document.data()))
.toList());
});
Widget build(BuildContext context) {
var result = useProvider(productSlpStreamProvider);
return result.when(
loading: () => Center(child: CircularProgressIndicator()),
error: (err, stack) {
print('PackageList Error: ${err.toString()}');
return Center(
child: InkWell(child: Text(err.toString()), onTap: () {}));
},
data: (List<ProductSlpModel> slpProduct) {
....
}
*MIGRATING CODE:*
final CollectionReference<ProductSlpModel> serviceProductCollectionRef =
firebaseFirestore
.collection(SERVICE_PRODUCT_COLLECTION)
.withConverter<ProductSlpModel>(
fromFirestore:
(DocumentSnapshot<Map<String, dynamic>> snapshot, _) =>
ProductSlpModel.formJson(snapshot.data()!),
toFirestore: (ProductSlpModel model, _) => model.toJson());
final AutoDisposeStreamProvider productSlpStreamProvider =
AutoDisposeStreamProvider((AutoDisposeProviderReference ref) {
return serviceProductCollectionRef.snapshots(); //.map((event) => event.docs);
});
Widget build(BuildContext context) {
AsyncValue _result =
useProvider(productSlpStreamProvider); //
return _result.when(
loading: () => SliverToBoxAdapter(
child: const Center(child: CircularProgressIndicator())),
error: (Object err, StackTrace? stack) => Text('Error $err'),
// ignore: always_specify_types
data: (slpProduct) { //<<<<<<<<<<< <List<ProductSlpModel>> ?
...
}
2021년 5월 5일 (수) 오후 9:04, Remi Rousselet ***@***.***>님이 작성:
… What does "throws an error" means?
What is the error?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#6028 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AL3TF7IAMGESY3KQIGW3DDLTMEX3FANCNFSM44EFXRFQ>
.
--
SINT Patrick
대표이사 공병주
Back Office
19, Wiryegwangjang-ro, Sujeong-gu, Seongnam-si, Gyeonggi-do, Republic of
Korea
Tel +82 02 400 8465 Mobile +82 010 5386 8880
Email ***@***.*** ***@***.***>
CONFIDENTIAL: The information contained in this e-mail transmission is
legally privileged and confidential. It may also be protected by law as
attorney work product and attorney-client privileged communication. It is
intended solely for the recipient(s) identified above. If you have received
this e-mail transmission in error or you are not the intended recipient,
please contact the sender immediately and destroy the transmission. Any
distribution, reproduction, or dissemination of the message in this e-mail
transmission is prohibited. Thank you for your cooperation in advance.
127, Beobwon-ro, Songpa-gu, Seoul, Republic of Korea (05836)
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am migrating to cloud firestore 2.0. There are some problems when importing data. What is the workaround?
Package:
freezed_annotation: ^0.14.1
json_annotation: ^4.0.1
@freezed
class UserModel with _$UserModel {
factory UserModel {
@default('') String uid,
@default('') String displayName,
@default('') String email,
.....
}) = _UserModel;
factory UserModel.formJson(Map<String, dynamic> data) =>
_$UserModelFromJson(data);
Map<String, dynamic> toJson() => _$UserModelToJson(this);
}
Migration Model
factory UserModel.formJson(Map<String, Object?> data) =>
_$UserModelFromJson(data);
**Error
QuerySnapshot snapshot =
await FirebaseFirestore.instance.collection(USERS_COLLECTION).get();
**Code
Beta Was this translation helpful? Give feedback.
All reactions