JavaScript Client SDK
Class Index | File Index

Classes


Class SchemaBuilder

The SchemaBuilder class creates a schema either programmatically or by parsing an XML file. You typically write the schema to a Schema object by calling the SchemaBuilder.toSchema() method. The SchemaBuilder can take in an optional Document object as a parameter. This object must be passed in when creating a schema using an input XML file.
Defined in: SchemaBuilder.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Creates a new SchemaBuilder object.
Method Summary
Method Attributes Method Name and Description
 
addField(inpField)
Add a field to the schema.
 
addIndex(inpIndex)
Add an index to the schema.
 
removeField(fieldName)
Remove a field from the schema.
 
removeIndex(indexName)
Remove an index field from the schema.
 
Get the current schema represented in this SchemaBuilder as an Object.
Class Detail
SchemaBuilder()
Creates a new SchemaBuilder object.
Method Detail
{SchemaBuilder} addField(inpField)
Add a field to the schema.

The object passed to this method is a JavaScript Map with the following fields:

  • name - A required field of type String that specifies the field name.
  • type - A required field of type String that specifies the data type of the field as either "string", "integer", "real", "date", or "binary".
  • isKey - An optional Boolean value set to true if this is a primary key. The default value is false.
  • isNullable - An optional boolean value set to true if this field is nullable. The default value is false.
Parameters:
{Object} inpField
The field to add.
Since:
1.0.1
Throws:
Error, if the field is null/not in proper format
Returns:
{SchemaBuilder} A reference to this SchemaBuilder object.
{SchemaBuilder} addIndex(inpIndex)
Add an index to the schema.

The object passed to this method is a JavaScript Map with the following fields:

  • name - A required field of type String that specifies the index name.
  • fields - A required field containing an Array of strings that specifies the names of the index fields. Fields used as an index must have been added by the addField() method.
Parameters:
{Object} inpIndex
The index to add.
Since:
1.0.1
Throws:
Error, if the index is null, not in proper format or if the fields referenced in the index have not been added
Returns:
{SchemaBuilder} A reference to this SchemaBuilder object.
{SchemaBuilder} removeField(fieldName)
Remove a field from the schema.
Parameters:
{string} fieldName
The name of the field to remove.
Since:
1.0.1
Throws:
Error if the field to be removed does not exist
Returns:
{SchemaBuilder} A reference to this SchemaBuilder object.
{SchemaBuilder} removeIndex(indexName)
Remove an index field from the schema.
Parameters:
{string} indexName
The name of the index to remove.
Since:
1.0.1
Throws:
Error, if the index is null/does not exist
Returns:
{SchemaBuilder} A reference to this SchemaBuilder object.
{Object} toSchema()
Get the current schema represented in this SchemaBuilder as an Object. Validates that the values in this SchemaBuilder represent a valid schema before returning. Once validated, a new schema object is created with the values currently in this SchemaBuilder and returned. Subsequent changes on the SchemaBuilder do not affect the returned schema object.

The schema object contains an internal representation of the schema, and the following methods:

  • getFields() - Returns an object containing all the fields of the schema.
  • getKeyFields() - Returns an object containing all the key fields of the schema.
  • getIndexes() - Returns an object containing all the index fields of the schema.
Since:
1.0.1
Throws:
Error if schema validations fail
Returns:
{Object} A valid schema object representing the current values in this schema builder.

©2013 Verivo Software, Inc. Documentation generated by JsDoc Toolkit 2.4.0 on Mon Apr 27 2015 15:06:19 GMT-0400 (EDT)