Not what i asked for.
How to import/export a flow
You can use the copy value icon in debug 3 to show us the db return in msg.database.
Here is an example of how to do it inline in a single message.
[{"id":"a64548953fdaac3b","type":"inject","z":"b9860b4b9de8c8da","name":"in","props":[{"p":"currentTag","v":"1234","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":570,"y":160,"wires":[["d9dec6e565ce4d56"]]},{"id":"d9dec6e565ce4d56","type":"template","z":"b9860b4b9de8c8da","name":"simulate db","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"[\n{\"tag_id\":\"1234\"},\n{\"tag_id\":\"5678\"}\n]","output":"json","x":730,"y":160,"wires":[["9e6d4ad7bb97b75b"]]},{"id":"9e6d4ad7bb97b75b","type":"change","z":"b9860b4b9de8c8da","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"database","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":970,"y":160,"wires":[["b25f8066f59ddfcb"]]},{"id":"92e0c3d4270ce657","type":"template","z":"b9860b4b9de8c8da","name":"simulate db","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"[\n{\"tag_id\":\"2345\"},\n{\"tag_id\":\"5678\"}\n]","output":"json","x":730,"y":220,"wires":[["9e6d4ad7bb97b75b"]]},{"id":"b25f8066f59ddfcb","type":"function","z":"b9860b4b9de8c8da","name":"","func":"var tagToCheck = msg.currentTag\nvar results = msg.database;\n\nvar tagExists = false;\nfor (var i = 0; i < results.length; i++) {\n if (results[i].tag_id === tagToCheck) {\n tagExists = true;\n break;\n }\n}\n\nif (tagExists) {\n msg.payload1 = \"Tag cadastrada!\";\n} else {\n msg.payload1 = \"Tag não cadastrada!\";\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1140,"y":160,"wires":[["15a71ced56e8e7f8"]]},{"id":"594ee668eb3d16db","type":"inject","z":"b9860b4b9de8c8da","name":"not in","props":[{"p":"currentTag","v":"1234","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":570,"y":220,"wires":[["92e0c3d4270ce657"]]},{"id":"15a71ced56e8e7f8","type":"debug","z":"b9860b4b9de8c8da","name":"debug 334","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload1","targetType":"msg","statusVal":"","statusType":"auto","x":1010,"y":260,"wires":[]}]
Here is a join example
[{"id":"a64548953fdaac3b","type":"inject","z":"b9860b4b9de8c8da","name":"in","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1234","payloadType":"str","x":570,"y":60,"wires":[["d9dec6e565ce4d56","5edfe004614a3947"]]},{"id":"d9dec6e565ce4d56","type":"template","z":"b9860b4b9de8c8da","name":"simulate db","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"[\n{\"tag_id\":\"1234\"},\n{\"tag_id\":\"5678\"}\n]","output":"json","x":610,"y":140,"wires":[["9e6d4ad7bb97b75b"]]},{"id":"5edfe004614a3947","type":"change","z":"b9860b4b9de8c8da","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"tag","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":60,"wires":[["7f4f5fe9fb6c4c1a"]]},{"id":"9e6d4ad7bb97b75b","type":"change","z":"b9860b4b9de8c8da","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"db","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":140,"wires":[["7f4f5fe9fb6c4c1a"]]},{"id":"7f4f5fe9fb6c4c1a","type":"join","z":"b9860b4b9de8c8da","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":970,"y":100,"wires":[["b25f8066f59ddfcb"]]},{"id":"b25f8066f59ddfcb","type":"function","z":"b9860b4b9de8c8da","name":"","func":"var tagToCheck = msg.payload.tag\nvar results = msg.payload.db;\n\nvar tagExists = false;\nfor (var i = 0; i < results.length; i++) {\n if (results[i].tag_id === tagToCheck) {\n tagExists = true;\n break;\n }\n}\n\nif (tagExists) {\n msg.payload1 = \"Tag cadastrada!\";\n} else {\n msg.payload1 = \"Tag não cadastrada!\";\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1140,"y":140,"wires":[["15a71ced56e8e7f8"]]},{"id":"15a71ced56e8e7f8","type":"debug","z":"b9860b4b9de8c8da","name":"debug 334","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload1","targetType":"msg","statusVal":"","statusType":"auto","x":1010,"y":240,"wires":[]}]
But would it not be better to query db select * from db_table where tag_id = "1234"
and if array length is 0 then no tag was found in query result returned for select query.