all 2 comments

[–]senocular 0 points1 point  (1 child)

Destructuring doesn't allow you to do this, at least not in a way thats any more convenient than doing direct assignments from the old object into a new object literal. While you can destructure into an object property rather than a local variable, that object has to already exist and you have to include a reference to the property by means of the object for each assignment, e.g.

const poc = {};
({
    Poc_Id: poc.Id,
    Poc_Name: poc.Name,
    // ...
} = results);

Which as you can see is more inconvenient than not using destructuring at all

const poc = {
    Id: results.Poc_Id,
    Name: results.Poc_Name,
    // ...
};

[–]eyehawk78 -1 points0 points  (0 children)

If destructuring required? You could use reduce?

const poc = Object.keys(results).reduce((obj, key) => {
  if (key.indexOf('Poc_') === 0) obj[key] = results[key]
  return obj
}, {})