01b/ Query new person record
Metadata
- Name: 01b/ Query new person record
- Adaptor:
@openfn/language-mysql
- Adaptor Version:
latest
- Created almost 5 years ago
- Updated over 4 years ago
- Score: 0 (an indicator of how useful this job may be)
Key Functions
alterState
Expression
sqlString(state => {
// The person information is in state from the previous operation
console.log(state.references[0].RegistrationForm)
return (
`SELECT id FROM hippo_person WHERE firstname='` +
state.references[0].RegistrationForm.first_name +
`' AND surname='` +
state.references[0].RegistrationForm.last_name +
`'`
);
});
alterState(state => {
// Note: we pluck out on the 'RowDataResponses' from the SQL server.
const personData = state.response.body;
console.log(personData);
// Get the first record
state.data.person_id = personData[0] && personData[0].id
return state;
});