mostlyserious / riak-js

Riak client for Javascript
http://riak-js.org
476 stars 102 forks source link

How can I get metadata with getAll? #194

Closed cranic closed 10 years ago

cranic commented 11 years ago

Hello there,

The documentation of getAll says that it returns an array of objects with the data and de meta of the document, but running getAll all I can see is the data of the document.

How can I grab the metadata of each document?

sideshowcoder commented 11 years ago

Well you don't get the metadata for each document but one meta data object. Getall internally runs a mapreduce something like

curl -XPOST http://localhost:8098/mapred \
      -H 'Content-Type: application/json' \
      -d '{"inputs": "test_data", "query":[{"map": {"language": "javascript","source": "Riak.mapValuesJson"}}] }'

on the shell would give you. If you need to get the metadata for each object you would have to get each object, or at least make a head request, so like

db.exists("bucket", "key", function(err, res, meta) { console.log(meta) })

for each key.