Users of IBM Cloudant and IBM App Connect can now define the properties of their documents more easily.
Let’s look at an example. Imagine you want to store a user’s details in Cloudant. The properties data structure might be something like the following:
- Name (string)
- Number (number)
- Name (string)
- Street (string)
- City (string)
- Zip (string)
- Birthdate (date)
When you create your flow in App Connect with an action such as Create Document you see the document object with the option for you to add properties, as shown in the following image:
Click Add property. As a result, a new property appears and you can set its name and data type. For the example above, enter ‘Name’ and leave the type as String.
To add another property, click Add property again. This time enter the name ‘Address’, but change the type to Object. You should now see a second Add property option appear for the Address object. This allows you to define the properties within the Address object.
Continue to define the other properties: Number, Name, Street, City, and Zip. Setting Number to the data type Number means that App Connect will require that a number be mapped to the field for the Number property.
Finally, click the outer Add property and enter ‘Birthdate’, specifying the type to be Date.
You should now have your document defined as follows.
You are now ready to use your document, just as if it had been defined as part of the action all along. Click Edit mappings to save your changes and show fields for the properties ready to be completed. You can map to these fields from source fields of nodes earlier in the flow, just as you would for other actions in App Connect. A completed mapping might look something like the following image:
If you need to make any changes to the properties data structure, simply clicking Edit properties will allow you to switch back in to the properties editor.
When you have completed the properties and triggered your flow you will see a document in your Cloudant database like the following image:
With this powerful functionality you can now specify complex objects with ease and without errors as App Connect takes care of all the JSON. This is available for IBM Cloudant and other applications that allow you to specify your own objects.