Hello Good peoples,
I have a problem that id like some advice on
I am pulling from a web API to see if the worker is on shift and working.
I can pull the data no problem but I need to do is if the "shift_on" value is true then not write the record
I have a function node to pull the 3 variables and output
which outputs
Im banging my head against the proverbal wall here, I dont know what way to proceed
Is there a easier or better way to do this other than writing JS to do it?
Any help is appreciated.
Thanks
const output = msg.payload.users.user.reduce((acc, curr) => {
return acc.concat({ shift_on: curr.shift_on[0], name: curr.name[0], notes: curr.notes[0] });
}, []).filter(( u ) => u.shift_on === "false")
EDIT: the boolean you wanted other way
EDIT2 : and you don't have boolean but strings
this sounds like a double negative, you want to exclude shift_on: "true"
?
You can use a change node with a JSONata expression:
**[shift_on != "true"]
Thanks Gents.
Both worked.
I am not 100% with JSONata queries yet.. still getting my head around it
I just need to find in notes and filter that too.. I will try and use match ? in JSONata
Is there a easy way to learn more about JSONata queries other than reading the website?