.Dataset().Insert()
Task<TRowData> api
.Dataset(...)
.Insert(IEnumerable<KeyValuePair<string, string>>data)
Insert a new row into a a given data set.
IEnumerable
object (e.g. a List<KeyValuePair<string, string>>
or Dictionary<string, string>
) which contains properties whose names start dp-
for data points and l-
for links..Dataset().Schema()
method or refer to the "ID" for the data point which can be found in the Data set inspector of the Data tab for the data set. The number of dp-{number}
parameters will depend upon the number of data points configured for the data set. Each is optional (unless a "Required" validator is set for the data point) and will take the default value if not specified.public class TRowEditData {
public dynamic data;
public string error;
public TFieldErrors[] fieldErrors;
public bool success;
}
public class TFieldErrors {
public string name;
public string status;
}
This method returns a Task
which will resolve to an TRowEditData
instance which is largely the same as that returned by the .Dataset().Row().Data()
method with the addition of the fieldErrors
property which contains information about individual field inputs should validation of any of them fail.
Consider the following being sent with two text fields that have values to be set:
var api = new CloudTables.Api(":apiKey")
.Domain(":domainOrIp");
var result = await api
.Dataset(":id")
.Insert(new Dictionary<string, string>() {
{"dp-11", "Supersonic"},
{"dp-15", "Boom"}
});
To get the id
of the newly inserted row:
Console.WriteLine(
result.data.id
);
In the following example we have linked data where our data set has two links; the first (l-4
) expects a single value (the id of the row being linked to) and the second (l-6
) is a multi-link and can have multiple values - here we give it three rows to link to. Note that to clear all links, use an empty array ("[]"
).
var api = new CloudTables.Api(":apiKey")
.Domain(":domainOrIp");
var result = await api
.Dataset(":id")
.Insert(new Dictionary<string, string>() {
{"dp-11", "Supersonic"},
{"l-4", "11"},
{"l-6", "[3,7,21]"}
});