This optional property indicates when and how the server automatically sets the field value.
Only one of these values is allowed per field.
-
"none"indicates that the server does not automatically set the field's value. -
"incrementOnInsert"indicates that the server automatically increments a field’s value each time the server inserts a new record. It applies to fields that are of the type of decimal or one of the integer types, such as"bigint". Only one field per table can have this attribute. The server returns an error when assigning this attribute to multiple fields. The JSON DB API automatically creates the"id"field as an"incrementOnInsert"field. If you apply this attribute to another field, it becomes the only automatically incremented field in the table. If you want that field to be the primary key, assign"primaryKey": 1to it. -
"timestampOnInsert"indicates that the server automatically sets a field’s value to the current date and time of an insert. It applies only to fields with a type of"timestamp".- If you attempt to insert a record and specify a timestamp for a field that has
"autoValue"set to"timestampOnInsert", the timestamp you specified is ignored, and the current date and time are assigned to the field.
- If you attempt to insert a record and specify a timestamp for a field that has
-
"timestampOnUpdate"indicates that the server automatically sets a field’s value to the current date and time of an update. This setting applies only to timestamp fields. -
"timestampOnUpdateAndInsert"indicates that the server automatically sets a field’s value to the current date and time of an insert and an update. It applies only to fields with a type of"timestamp". -
"changeId"indicates the server uses the field for optimistic locking. The server automatically sets the field's value to the internal transaction number used during the last update of the record. This value changes each time the server updates the record. A table may only have one change tracking field. The field type must be"bigint".
The JSON DB API automatically creates a"changeid"field with change-tracking functionality.
Change tracking is optional in the CTDB and ISAM APIs. The application must create a 64-bit integer field and assign change-tracking functionality to it.
Request Example
"fields": [
{
"name": "signed_int32",
"type": "integer",
"autoValue": "incrementOnInsert"
}
]
Response Example
{
"result": {
"dataFormat": "objects",
"data": [
{
"changeIdField": "changeId",
"createRecByteIndex": false,
"databaseName": "ctreeSQL",
"fieldDelimiterValue": 0,
"fields": [
{
"autoValue": "incrementOnInsert",
"defaultValue": null,
"length": null,
"name": "signed_int32",
"nullable": true,
"primaryKey": 0,
"scale": null,
"type": "integer"
}
]
}
]
},
"errorCode": 0,
"errorMessage": "",
"authToken": "replaceWithAuthTokenFromCreateSession"
}