tibasFieldDef_Create()

Returns a new FieldDef instance. The default value of the field is “not nullable.”

Declaration

tibas_status tibasFieldDef_Create
(tibasFieldDef*  fieldDef,
char*            fieldName,
tibas_type       fieldType)

Parameters

Parameter Description
fieldDef The new instance of a field definition returned by the function
fieldName The field name.
fieldType The field type.

Remarks

Use the tibasFieldDef_Create() function to create a new field definition. The field definition is returned in a fieldDef object that you pass to the function.

The fieldName parameter specifies a string, enclosed in double quotes, that represents the field name.

The fieldType parameter specifies the type for the field. This can be any of the data types listed in the tibas_type enumeration (See tibas_type for the enumeration that lists the data types).

After you have created the fields for a tuple by calling tibasFieldDef_Create(), you can assign the fields to a spaceDef object by calling the tibasSpaceDef_PutFieldDef() function and assign a key value by calling the tibasSpaceDef_SetKey() function.

Example

tibasSpaceDef spaceDef = NULL;
tibasFieldDef keyField = NULL;
tibasFieldDef valueField = NULL;
tibasFieldDef timeField = NULL;
char const* spaceName = "myspace";
tibasFieldDef_Create(&keyField, "key", TIBAS_INTEGER);
tibasFieldDef_Create(&valueField, "value", TIBAS_STRING);
tibasFieldDef_SetNullable(valueField, TIBAS_TRUE);
tibasFieldDef_Create(&timeField, "time", TIBAS_DATETIME);
tibasFieldDef_SetNullable(timeField, TIBAS_TRUE);
tibasSpaceDef_Create(&spaceDef);
tibasSpaceDef_PutFieldDef(spaceDef, keyField);
tibasSpaceDef_PutFieldDef(spaceDef, valueField);
tibasSpaceDef_PutFieldDef(spaceDef, timeField);
tibasSpaceDef_SetKey(spaceDef, "key")