Skip to content

Instantly share code, notes, and snippets.

@lgfa29
Created April 15, 2016 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lgfa29/6e2d0e61fd2874e848defd9aaa064b08 to your computer and use it in GitHub Desktop.
Save lgfa29/6e2d0e61fd2874e848defd9aaa064b08 to your computer and use it in GitHub Desktop.
CRUD sample for the Cloudant node on Node-RED. Copy the whole JSON string below and import it into Node-RED
[
{
"id": "468a1325.bb66dc",
"type": "cloudant out",
"z": "255c3a8b.88f8a6",
"name": "",
"cloudant": "",
"database": "crud",
"service": "node-red-cloudant-test-luiz-cloudantNoSQLDB",
"payonly": true,
"operation": "insert",
"x": 343.5,
"y": 150,
"wires": []
},
{
"id": "9675a025.00271",
"type": "inject",
"z": "255c3a8b.88f8a6",
"name": "Create new document",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"x": 159.5,
"y": 150,
"wires": [
[
"468a1325.bb66dc"
]
]
},
{
"id": "235bc400.181f0c",
"type": "inject",
"z": "255c3a8b.88f8a6",
"name": "Update first document",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"x": 157.5,
"y": 261,
"wires": [
[
"574a72a5.b6bebc"
]
]
},
{
"id": "574a72a5.b6bebc",
"type": "cloudant in",
"z": "255c3a8b.88f8a6",
"name": "",
"cloudant": "",
"database": "crud",
"service": "node-red-cloudant-test-luiz-cloudantNoSQLDB",
"search": "_all_",
"design": "",
"index": "",
"x": 342.5,
"y": 261,
"wires": [
[
"feb5f36f.e8145"
]
]
},
{
"id": "feb5f36f.e8145",
"type": "function",
"z": "255c3a8b.88f8a6",
"name": "",
"func": "var doc = msg.payload[0];\ndoc.payload = Date.now();\n\nmsg.payload = doc;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 483.5,
"y": 261,
"wires": [
[
"e696edce.36114"
]
]
},
{
"id": "e696edce.36114",
"type": "cloudant out",
"z": "255c3a8b.88f8a6",
"name": "",
"cloudant": "",
"database": "crud",
"service": "node-red-cloudant-test-luiz-cloudantNoSQLDB",
"payonly": true,
"operation": "insert",
"x": 615.5,
"y": 261,
"wires": []
},
{
"id": "de9d1b5d.20b0b8",
"type": "inject",
"z": "255c3a8b.88f8a6",
"name": "Retrieve first document",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"x": 158.5,
"y": 202,
"wires": [
[
"62832382.5fc59c"
]
]
},
{
"id": "62832382.5fc59c",
"type": "cloudant in",
"z": "255c3a8b.88f8a6",
"name": "",
"cloudant": "",
"database": "crud",
"service": "node-red-cloudant-test-luiz-cloudantNoSQLDB",
"search": "_all_",
"design": "",
"index": "",
"x": 342.5,
"y": 202,
"wires": [
[
"a4f8c892.ebbe98"
]
]
},
{
"id": "934a3e44.25896",
"type": "debug",
"z": "255c3a8b.88f8a6",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 633.5,
"y": 202,
"wires": []
},
{
"id": "a4f8c892.ebbe98",
"type": "function",
"z": "255c3a8b.88f8a6",
"name": "",
"func": "msg.payload = msg.payload[0];\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 482.5,
"y": 202,
"wires": [
[
"934a3e44.25896"
]
]
},
{
"id": "6076f91.9e6c508",
"type": "inject",
"z": "255c3a8b.88f8a6",
"name": "Delete first document",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"x": 155.5,
"y": 317,
"wires": [
[
"87edfd87.5c6d4"
]
]
},
{
"id": "87edfd87.5c6d4",
"type": "cloudant in",
"z": "255c3a8b.88f8a6",
"name": "",
"cloudant": "",
"database": "crud",
"service": "node-red-cloudant-test-luiz-cloudantNoSQLDB",
"search": "_all_",
"design": "",
"index": "",
"x": 340,
"y": 317,
"wires": [
[
"cc7aec59.c2141"
]
]
},
{
"id": "cc7aec59.c2141",
"type": "function",
"z": "255c3a8b.88f8a6",
"name": "",
"func": "msg.payload = msg.payload[0];\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 480,
"y": 317,
"wires": [
[
"fbe3c826.de4f58"
]
]
},
{
"id": "fbe3c826.de4f58",
"type": "cloudant out",
"z": "255c3a8b.88f8a6",
"name": "",
"cloudant": "",
"database": "crud",
"service": "node-red-cloudant-test-luiz-cloudantNoSQLDB",
"payonly": false,
"operation": "delete",
"x": 614.5,
"y": 317,
"wires": []
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment