-
Notifications
You must be signed in to change notification settings - Fork 664
How to create a cleaned up contact object of an array of contact data
agershun edited this page Dec 28, 2014
·
1 revision
Source: StackOverflow.com
There is an array with objects like this:
[
{
id: '1',
name: 'Joe',
description: 'Student',
locations: [ {
type: 'home',
value: '123'
} ]
},
{
id: '1',
name: 'Joe',
description: 'Farmer',
locations: [ {
type: 'home',
value: '456'
} ]
},
{
id: '1',
name: 'Joe',
description: '',
locations: [ {
type: 'home',
value: '123'
} ]
}
]
How to create the following? :
{
id: '1',
name: 'Joe',
description: 'Farmer',
locations: [ {
type: 'home',
value: '123'
}, {
type: 'home',
value: '456'
} ]
}
var res = alasql('SELECT id, FIRST(name) AS name, FIRST(description) AS description, \
ARRAY(locations->0) AS locations FROM ?',[data]);
See the example at jsFiddle
© 2014-2024, Andrey Gershun & Mathias Rangel Wulff
Please help improve the documentation by opening a PR on the wiki repo