Created
June 24, 2024 07:35
-
-
Save djinn/e8baed454f21424dfa4a2bc253f8458d to your computer and use it in GitHub Desktop.
How to do Multi Get in Couchbase SDK 4 node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const users = [ | |
{ id: 'user_111', email: '[email protected]' }, | |
{ id: 'user_222', email: '[email protected]' }, | |
{ id: 'user_333', email: '[email protected]' }, | |
] | |
// Wait for all the get operations to complete and store the results. | |
const getResults = await Promise.all( | |
users.map((user) => { | |
console.log(`Getting document: ${user.id}`) | |
return usersCollection.get(user.id, user) | |
}) | |
) | |
// Iterate the results and print the CAS metadata. | |
getResults.forEach((result) => console.log('Document:', result.content)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment