Arrays Flatter Firestore:FieldValue.arrayRemove(arr)工作异常
我正在尝试从firebase Firestore的数组中删除一个元素。这是下面的代码Arrays Flatter Firestore:FieldValue.arrayRemove(arr)工作异常,arrays,flutter,google-cloud-firestore,flutter-layout,Arrays,Flutter,Google Cloud Firestore,Flutter Layout,我正在尝试从firebase Firestore的数组中删除一个元素。这是下面的代码 await firestore.collection('posts') .doc(post.postId) .set( { 'replies': { commentId: FieldValue.arrayRemove([temp]), } }, SetOptions(merge: true), ); 我面临的问题是,
await firestore.collection('posts')
.doc(post.postId)
.set(
{
'replies': {
commentId: FieldValue.arrayRemove([temp]),
}
},
SetOptions(merge: true),
);
我面临的问题是,当我删除之前添加的任何数据时,它会被删除。但是,当我添加任何数据并使用上述代码将其删除时,它不会从Firestore中删除
我无法理解为什么会发生这种情况。两种情况下添加数据的功能相同。用于添加数据的代码
await firestore.collection('posts')
.doc(post.postId)
.set({
'replies': {
'$commentId': FieldValue.arrayUnion([replyModel.toMap()]),
}
}, SetOptions(merge: true));
我数据库的结构是这样的