internal CreateCollectionIndexStatement(Collection collection, string indexName, DbDoc indexDefinition) : base(collection)
        {
            // Fields allowed at the root level.
            var allowedFields = new string[] { "fields", "type" };

            // Fields allowed for embedded documents.
            var allowedInternalFields = new string[] { "field", "type", "required", "options", "srid", "array" };

            // Validate the index follows the allowed format.
            if (!indexDefinition.values.ContainsKey(allowedFields[0]))
            {
                throw new FormatException(string.Format(ResourcesX.MandatoryFieldNotFound, allowedFields[0]));
            }

            // Validate that fields on the root level are allowed.
            foreach (var field in indexDefinition.values)
            {
                if (!allowedFields.Contains(field.Key))
                {
                    throw new FormatException(string.Format(ResourcesX.UnexpectedField, field.Key));
                }
            }

            // Validate embedded documents.
            foreach (var item in indexDefinition.values[allowedFields[0]] as Object[])
            {
                var field = item as Dictionary <string, object>;

                // Validate embedded documents have the field field.
                if (!field.ContainsKey(allowedInternalFields[0]))
                {
                    throw new FormatException(string.Format(ResourcesX.MandatoryFieldNotFound, allowedInternalFields[0]));
                }

                // Validate embedded documents have the type field.
                if (!field.ContainsKey(allowedInternalFields[1]))
                {
                    throw new FormatException(string.Format(ResourcesX.MandatoryFieldNotFound, allowedInternalFields[1]));
                }

                foreach (var internalField in field)
                {
                    if (!allowedInternalFields.Contains(internalField.Key))
                    {
                        throw new FormatException(string.Format(ResourcesX.UnexpectedField, internalField.Key));
                    }
                }
            }

            createIndexParams = new CreateIndexParams(indexName, indexDefinition);
        }
 internal CreateCollectionIndexStatement(Collection collection, string indexName, bool isUnique) : base(collection)
 {
     createIndexParams = new CreateIndexParams(indexName, isUnique);
 }