Please explain this JavaScript language construct:
cursor => cursor.map(doc => doc._key)
in this context
collection.all().then(
cursor => cursor.map(doc => doc._key) // this line
).then(
keys => console.log('All keys:', keys.join(', ')),
err => console.error('Failed to fetch all documents:', err)
);
Don't understand the doc => doc._key
as parameter to the map()
function. Why will it not work with doc => { key: doc._key, name: doc.name}
?