Javascript 为什么Firestore在创建复合索引后仍然产生错误?
我有一个叫做用户的firestore集合。 以下是我感兴趣执行的三个DB读取: 1: 2: 3: 示例用户文档具有以下字段: 用户名 法律名称 角色 忙碌的 创建数据 终身收件箱 终身阅读 我创建了以下综合索引: 还尝试: 我的问题是,即使在创建复合索引之后,我试图解决的初始错误仍然存在 错误:Firestore:操作被拒绝,因为系统未处于执行该操作所需的状态。firestore/预处理失败Javascript 为什么Firestore在创建复合索引后仍然产生错误?,javascript,firebase,google-cloud-firestore,Javascript,Firebase,Google Cloud Firestore,我有一个叫做用户的firestore集合。 以下是我感兴趣执行的三个DB读取: 1: 2: 3: 示例用户文档具有以下字段: 用户名 法律名称 角色 忙碌的 创建数据 终身收件箱 终身阅读 我创建了以下综合索引: 还尝试: 我的问题是,即使在创建复合索引之后,我试图解决的初始错误仍然存在 错误:Firestore:操作被拒绝,因为系统未处于执行该操作所需的状态。firestore/预处理失败 如何解决这一问题?在将我的工作限制在只更改并使用不同的复合索引之后,我意识到where和orderBy参
如何解决这一问题?在将我的工作限制在只更改并使用不同的复合索引之后,我意识到where和orderBy参数中的所有内容以及查询的集合都需要包括在内。所以就我而言 需要包含字段的复合索引 角色asc 主动asc 创建数据asc 需要包含字段的复合索引 角色asc 主动asc 终身收件箱asc 需要包含字段的复合索引 角色asc 主动asc 终身阅读 现在错误消失了
const onNewestChange = (dispatch) => {
firebase
.firestore()
.collection('users')
.where('role', '==', 'a')
.where('active', '==', true)
.orderBy('createdAt')
.limit(10)
.onSnapshot((querySnapshot) => {
const newestProfiles = querySnapshot.forEach((queryDocSnapshot) => {
const profile = queryDocSnapshot.data();
newestProfiles.push(profile);
});
dispatch({ type: types.LOAD_NEWEST, payload: newestProfiles });
});
};
const onMostPopularChange = (dispatch) => {
firebase
.firestore()
.collection('users')
.where('role', '==', 'a')
.where('active', '==', true)
.orderBy('lifetimeInbox')
.limit(10)
.onSnapshot((querySnapshot) => {
const popularProfiles = querySnapshot.forEach((queryDocSnapshot) => {
const profile = queryDocSnapshot.data();
popularProfiles.push(profile);
});
dispatch({ type: types.LOAD_POPULAR, payload: popularProfiles });
});
};
const onMostActiveChange = (dispatch) => {
firebase
.firestore()
.collection('users')
.where('role', '==', 'a')
.where('active', '==', true)
.orderBy('lifetimeRead')
.limit(10)
.onSnapshot((querySnapshot) => {
const activeProfiles = querySnapshot.forEach((queryDocSnapshot) => {
const profile = queryDocSnapshot.data();
activeProfiles.push(profile);
});
dispatch({ type: types.LOAD_ACTIVE, payload: activeProfiles });
});
};