selfup / exdaas

RESTful Elixir Database as a Service! Fault Tolerant, Self Sharding, Self Caching, Single Table, Persistent Key Value Store :tada:
MIT License
9 stars 1 forks source link

Cmd queries with values #5

Closed selfup closed 6 years ago

selfup commented 6 years ago

Implement ONLY query that takes keys which then returns values in order of the keys.

Examples in JavaScript:

const query = 'ONLY';
const keys = ['color'];

axios.get('http://whatever.com/api/cmd', {
  data: {
    query,
    keys,
  },
})
  .then(...)
  .catch(...);

The response will be:

{
  values: ['blue'],
}

So now if you want to build an object based off the response, something simple like:

const newObj = {};

keys.forEach((key, i) => newObj[key] = values[i]); 

Considering just returning a valid object..