84669 人学习
152542 人学习
20005 人学习
5487 人学习
7821 人学习
359900 人学习
3350 人学习
180660 人学习
48569 人学习
18603 人学习
40936 人学习
1549 人学习
1183 人学习
32909 人学习
实际上,您会像这样使用 firestore.getAll
async getUsers({userIds}) { const refs = userIds.map(id => this.firestore.doc(`users/${id}`)) const users = await this.firestore.getAll(...refs) console.log(users.map(doc => doc.data())) }
或者使用 Promise 语法
getUsers({userIds}) { const refs = userIds.map(id => this.firestore.doc(`users/${id}`)) this.firestore.getAll(...refs).then(users => console.log(users.map(doc => doc.data()))) }
如果您在 Node 中:
https://github.com/ googleapis/nodejs-firestore/blob/master/dev/src/index.ts#L978
/** * Retrieves multiple documents from Firestore. * * @param {...DocumentReference} documents - The document references * to receive. * @returns {Promise<Array.<DocumentSnapshot>>} A Promise that * contains an array with the resulting document snapshots. * * @example * let documentRef1 = firestore.doc('col/doc1'); * let documentRef2 = firestore.doc('col/doc2'); * * firestore.getAll(documentRef1, documentRef2).then(docs => { * console.log(`First document: ${JSON.stringify(docs[0])}`); * console.log(`Second document: ${JSON.stringify(docs[1])}`); * }); */
这是专门针对服务器 SDK 的
更新:Cloud Firestore 现在支持 IN 查询!
myCollection.where(firestore.FieldPath.documentId(), 'in', ["123","456","789"])
实际上,您会像这样使用 firestore.getAll
或者使用 Promise 语法
如果您在 Node 中:
https://github.com/ googleapis/nodejs-firestore/blob/master/dev/src/index.ts#L978
这是专门针对服务器 SDK 的
更新:Cloud Firestore 现在支持 IN 查询!