【发布时间】:2020-07-27 23:44:52
【问题描述】:
我一直在谷歌上搜索如何将对象添加到 firestore 中的数组中,并发现 arrayUnion() 能够将对象添加到 firestore 数组中,但它只将对象添加到数组的最后一个索引中,但是如何将其添加到数组的第一个索引中?
//add "greater_virginia" into last index of array
washingtonRef.update({
regions: firebase.firestore.FieldValue.arrayUnion("greater_virginia")
});
//how to add "greater_virginia" into first index of array?
它与arrayUnion 基本相同,但我不想将其添加到最后一个索引中,而是将其添加到数组的第一个索引中。
【问题讨论】:
标签: javascript arrays reactjs react-native google-cloud-firestore