Skip to content

Instantly share code, notes, and snippets.

@djinn
Created June 24, 2024 07:35
Show Gist options
  • Save djinn/e8baed454f21424dfa4a2bc253f8458d to your computer and use it in GitHub Desktop.
Save djinn/e8baed454f21424dfa4a2bc253f8458d to your computer and use it in GitHub Desktop.
How to do Multi Get in Couchbase SDK 4 node.js
const users = [
{ id: 'user_111', email: 'tom_the_cat@gmail.com' },
{ id: 'user_222', email: 'jerry_mouse@gmail.com' },
{ id: 'user_333', email: 'mickey_mouse@gmail.com' },
]
// 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