Created
February 24, 2016 04:38
-
-
Save trustmaster/aa85e518db2444234526 to your computer and use it in GitHub Desktop.
Example component prototype
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c = new noflo.Component | |
c.desciption = 'A component that posts on behalf of user' | |
c.inPorts = new noflo.InPorts | |
db: | |
datatype: 'object' | |
control: true | |
user: | |
datatype: 'object' | |
post: | |
datatype: 'object' | |
c.outPorts = new noflo.OutPorts | |
id: | |
datatype: 'int' | |
c.process = (input, output, done) -> | |
return unless input.has 'db', 'user', 'post' # or input.has 'alternative' | |
[db, user, post] = input.receive 'db', 'user', 'post' | |
db.data 'post' | |
.insert | |
user: user.data.id | |
title: post.data.title | |
text: post.data.text | |
, 'id' | |
.then (rows) -> | |
output.sendDone | |
id: rows[0].id # new noflo.IP 'data', rows[0].id | |
.catch done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment