Flutter 无法在Flatter firestore中获取文档
我有一个名为boughtBy的字段,它包含购买优惠券的用户的所有ID。因此,我试图在作为数组的boughtBy字段中仅显示那些没有currentUsers id的优惠券 我的代码:-Flutter 无法在Flatter firestore中获取文档,flutter,google-cloud-firestore,Flutter,Google Cloud Firestore,我有一个名为boughtBy的字段,它包含购买优惠券的用户的所有ID。因此,我试图在作为数组的boughtBy字段中仅显示那些没有currentUsers id的优惠券 我的代码:- QuerySnapshot snapshotForCoupons=await couponsReference.where('visibility',isEqualTo: true).where('boughtBy',whereNotIn: [currentUser.id]).limit(10).get(); 但
QuerySnapshot snapshotForCoupons=await couponsReference.where('visibility',isEqualTo: true).where('boughtBy',whereNotIn: [currentUser.id]).limit(10).get();
但问题是它仍然显示包含当前用户id的优惠券。根据您的查询应该这样写:
QuerySnapshot snapshotforcoups=wait couponsReference.where('visibility',isEqualTo:true).where('boughtBy','not in',[currentUser.id]).limit(10.get();
I认为eroor是。where('boughtBy',whereNotIn:[currentUser.id])
这里currentUser是一个数组,您不能使用whereNotIn执行数组操作,可行的解决方案是在获取数组后使用。arrayContains
。