Requires
- module:lodash
Methods
(inner) select(columns, table) → {Array}
Executes the SQL SELECT statement on an Array of Objects.
Parameters:
Name | Type | Description |
---|---|---|
columns |
Array | An Array of Strings containting the columns the SELECT statement should return. |
table |
Array | The Array of Objects on which the SELECT statement should be executed. |
Returns:
- An Array of Objects containing only the selected columns, or the original array if called with ['*']
- Type
- Array
Examples
select(['*'], [{name: 'Bob', age: 55}, {name: 'Aisha', age: 34}])
// returns [{name: 'Bob', age: 55}, {name: 'Aisha', age: 34}]
select(['name, age'], [{name: 'Bob', age: 55}, {name: 'Aisha', age: 34}])
// returns [{name: 'Bob', age: 55}, {name: 'Aisha', age: 34}]
select(['age'], [{name: 'Bob', age: 55}, {name: 'Aisha', age: 34}])
// returns [{age: 55}, {age: 34}]