Hi all,
Just been looking through the API and came across batchMerge.
While this may be potentially quite useful, I found the documentation fairly impenetrable and difficult to ‘grok’.
Does anyone have a high level overview of this and when it’s used?
Hi Stamatis,
The merge API is powerful because it puts the workload on the target. You do not need to download data, write your own operations and then act accordingly with the results.
It allows you to do basic comparisons on the data you provide to the API with the existing data in your target (Cloud/Local).
For example:
Let's say you have a key that holds comma delimited data like car names:
If you have the following values: Toyota,Honda,Ford in the key and you want to introduce another car name in the list but not have it duplicated, you would use the merge operator of "is in" with a value of "Fiat". Fiat will be introduced into the list. If Fiat was already in the list, the API would not duplicate the value.
You might also use this if you are building relational data. You might store a recordID from one table to link data in another table. Your code would benefit from using Merge to insure that the recordID being stored is not duplicated in the key. This is the same as the previous example.
The operator "is not in" will do the inverse of "is in". It may be the second most used operator when using Merge. In our first example with cars, Fiat would be removed from the list of stored values.
The docs have been written to support different points of view for different learners. My favorite form is the code samples. It most aligns with how I think. For the most part, you could copy the code from there and paste it into a project. You may need to change tableNames to match what you have in your project to make the code work.
All Batch APIs are more complex because they provide the power to address multiple tables and records in a single call. Merge even lets you address multiple keys as well. The input is going to require an understanding of multi-dimensional arrays. The array is constructed in a logical way.
Try creating a test project with a single table, and a single key. You could create 2 or 3 records in LCM. Try Merging data into this test project. Experiment with the different operators to get a better grip on what they can do. Let us know how this works for you.
Thanks Mark,
your replies are always appreciated - I think the problem is my expectation vs reality.
The 'merge' method name made me think this may be a way to create a database cursor merging records from multiple tables (eg. related with foreign keys etc).
Trying to digest the examples in the documentation, this in fact seems to be a way to manipulate record data directly using liveCloud commands - in essence something similar to a batchUpdate but performed directly by liveCloud.
Is this correct or have i misunderstood?