YUKI Hiroshi
null+****@clear*****
Fri Nov 16 17:29:31 JST 2012
YUKI Hiroshi 2012-11-16 17:29:31 +0900 (Fri, 16 Nov 2012) New Revision: 46b4fd87cca3b3e95a941fcf8501a5b5662c91d4 https://github.com/groonga/gcs/commit/46b4fd87cca3b3e95a941fcf8501a5b5662c91d4 Log: Define list of valid options as class method of IndexField Modified files: lib/api/2011-02-01/configuration.js lib/database/index-field.js Modified: lib/api/2011-02-01/configuration.js (+13 -17) =================================================================== --- lib/api/2011-02-01/configuration.js 2012-11-16 17:16:45 +0900 (a73dd13) +++ lib/api/2011-02-01/configuration.js 2012-11-16 17:29:31 +0900 (7f4ce30) @@ -1,6 +1,7 @@ var path = require('path'); var nroonga = require('../../wrapped-nroonga'); var Domain = require('../../database').Domain; +var IndexField = require('../../database').IndexField; var dateFormat = require('dateformat'); var xmlbuilder = require('../../xmlbuilder'); var ipv4 = require('../../ipv4'); @@ -281,25 +282,20 @@ function createIndexFieldStatus(options) { return indexFieldStatus; } -var TEXT_TYPE_FIELD_OPTIONS = [ - 'IndexField.TextOptions.DefaultValue', - 'IndexField.TextOptions.FacetEnabled', - 'IndexField.TextOptions.ResultEnabled' - ]; -var LITERAL_TYPE_FIELD_OPTIONS = [ - 'IndexField.LiteralOptions.DefaultValue', - 'IndexField.LiteralOptions.FacetEnabled', - 'IndexField.LiteralOptions.ResultEnabled', - 'IndexField.LiteralOptions.SearchEnabled' - ]; -var UINT_TYPE_FIELD_OPTIONS = [ - 'IndexField.LiteralOptions.DefaultValue' - ]; +var TEXT_FIELD_OPTIONS = IndexField.TEXT_FIELD_OPTIONS.map(function(option) { + return 'IndexField.TextOptions.' + option; + }); +var LITERAL_FIELD_OPTIONS = IndexField.LITERAL_FIELD_OPTIONS.map(function(option) { + return 'IndexField.LiteralOptions.' + option; + }); +var UINT_FIELD_OPTIONS = IndexField.UINT_FIELD_OPTIONS.map(function(option) { + return 'IndexField.UIntOptions.' + option; + }); function assertValidFieldOptions(request, type, domainName) { - var validOptions = type == 'text' ? TEXT_TYPE_FIELD_OPTIONS : - type == 'literal' ? LITERAL_TYPE_FIELD_OPTIONS : - UINT_TYPE_FIELD_OPTIONS; + var validOptions = type == 'text' ? TEXT_FIELD_OPTIONS : + type == 'literal' ? LITERAL_FIELD_OPTIONS : + UINT_FIELD_OPTIONS; var options = Object.keys(request.query).filter(function(name) { return /^IndexField\.[^\.]+Options\./.test(name); Modified: lib/database/index-field.js (+23 -0) =================================================================== --- lib/database/index-field.js 2012-11-16 17:16:45 +0900 (72004ca) +++ lib/database/index-field.js 2012-11-16 17:29:31 +0900 (b966f94) @@ -40,6 +40,29 @@ var RESERVED_COLUMN_NAMES = '_key' ]; + +var TEXT_FIELD_OPTIONS = + IndexField.TEXT_FIELD_OPTIONS = + exports.TEXT_FIELD_OPTIONS = [ + 'DefaultValue', + 'FacetEnabled', + 'ResultEnabled' + ]; +var LITERAL_FIELD_OPTIONS = + IndexField.LITERAL_FIELD_OPTIONS = + exports.LITERAL_OPTIONS = [ + 'DefaultValue', + 'FacetEnabled', + 'ResultEnabled', + 'SearchEnabled' + ]; +var UINT_FIELD_OPTIONS = + IndexField.UINT_FIELD_OPTIONS = + exports.UINT_FIELD_OPTIONS = [ + 'DefaultValue' + ]; + + function assertValidFieldName(field) { if (typeof field != 'string') { var error = new Error('field name name must be a string'); -------------- next part -------------- HTML����������������������������... 下载