I have the following query in PostgreSQL:
select bookings."memberId" from bookings
join "memberConnections" mbc on bookings."memberId" = mbc."memberId"
join shifts shf on shf.id = bookings."shiftId"
where bookings.state = 'WAITING_LIST' and (mbc.state = 'LOCKED' or mbc.state = 'REMOVED')
and shf."startTime" > CURRENT_TIMESTAMP;
I'm importing it in a file then work the data through a library called Knex.js
When I run it and console log the query, I get the following structure:
USER_STATE: Result {
command: 'SELECT',
rowCount: 32,
oid: NaN,
rows:
[ anonymous { memberId: 1800 },
anonymous { memberId: 15476 },
anonymous { memberId: 15476 },
anonymous { memberId: 15476 },
anonymous { memberId: 12553 },
anonymous { memberId: 12553 },
anonymous { memberId: 19668 },
anonymous { memberId: 19668 },
anonymous { memberId: 21004 },
anonymous { memberId: 21004 },
anonymous { memberId: 21004 },
anonymous { memberId: 21004 },
anonymous { memberId: 16105 },
anonymous { memberId: 14927 },
anonymous { memberId: 15476 },
anonymous { memberId: 12553 },
anonymous { memberId: 12553 },
anonymous { memberId: 12553 },
anonymous { memberId: 12553 },
anonymous { memberId: 17923 },
anonymous { memberId: 17273 },
anonymous { memberId: 12553 },
anonymous { memberId: 12553 },
anonymous { memberId: 19429 },
anonymous { memberId: 17312 },
anonymous { memberId: 17273 },
anonymous { memberId: 15476 },
anonymous { memberId: 15476 },
anonymous { memberId: 15476 },
anonymous { memberId: 15476 },
anonymous { memberId: 15476 },
anonymous { memberId: 19634 } ],
fields:
[ Field {
name: 'memberId',
tableID: 22531,
columnID: 3,
dataTypeID: 23,
dataTypeSize: 4,
dataTypeModifier: -1,
format: 'text' } ],
_parsers: [ [Function: parseInteger] ],
RowCtor: [Function: anonymous],
rowAsArray: false,
_getTypeParser: [Function: bound ] }
Which is almost what I need, however, I just need the memberId data, is there any way how I could map through it to only get back the memberId properties?
I have tried this but it doesn't seem to work:
const users = userState.map(users => ({
memberId: memberId;
}))