SHIMODA Hiroshi
null+****@clear*****
Wed Aug 15 14:02:23 JST 2012
SHIMODA Hiroshi 2012-08-15 14:02:23 +0900 (Wed, 15 Aug 2012) New Revision: b194840c280195a90ef419f6435135059be77eb9 https://github.com/groonga/gcs/commit/b194840c280195a90ef419f6435135059be77eb9 Log: Sync methods can be chained Modified files: lib/database/domain.js lib/database/index-field.js Modified: lib/database/domain.js (+15 -0) =================================================================== --- lib/database/domain.js 2012-08-15 13:51:33 +0900 (42ce96f) +++ lib/database/domain.js 2012-08-15 14:02:23 +0900 (9491c97) @@ -270,6 +270,8 @@ Domain.prototype = { key_type: nroonga.ShortText, default_tokenizer: nroonga.TokenBigram }); + + return this; }, deleteSync: function() { @@ -285,12 +287,15 @@ Domain.prototype = { this.context.commandSync('table_remove', { name: this.termsTableName }); + + return this; }, reindexSync: function() { this.indexFields.forEach(function(field) { field.reindexSync(); }); + return this; }, getSynonymSync: function(key) { @@ -357,6 +362,8 @@ Domain.prototype = { table: this.synonymsTableName, values: JSON.stringify(values) }); + + return this; }, setupBlankSynonymsTable: function() { @@ -377,6 +384,8 @@ Domain.prototype = { type: nroonga.ShortText, flags: nroonga.COLUMN_VECTOR }); + + return this; }, hasSynonymsTableSync: function() { @@ -425,6 +434,7 @@ Domain.prototype = { table: this.tableName, values: JSON.stringify(values) }); + return this; }, toGrnDumpRecord: function(record) { @@ -449,6 +459,7 @@ Domain.prototype = { table: this.tableName, key: id }); + return this; }, setConfiguration: function(key, value) { @@ -462,6 +473,8 @@ Domain.prototype = { value: JSON.stringify(value) }]) }); + + return this; }, getConfiguration: function(key) { if (!this.context) @@ -489,6 +502,8 @@ Domain.prototype = { table: this.configurationsTableName, key: key }); + + return this; } }; Modified: lib/database/index-field.js (+10 -2) =================================================================== --- lib/database/index-field.js 2012-08-15 13:51:33 +0900 (e70105b) +++ lib/database/index-field.js 2012-08-15 14:02:23 +0900 (44fab14) @@ -285,9 +285,11 @@ IndexField.prototype = { }); this.saveOptionsSync(); + + return this; }, saveOptionsSync: function() { - if (!this.exists()) return; + if (!this.exists()) return this; this.facetEnabled; if (this._facetEnabled !== undefined) @@ -308,6 +310,8 @@ IndexField.prototype = { this.domain.defaultSearchField = this._defaultSearchField ? this : null ; delete this._defaultSearchField; } + + return this; }, deleteSync: function() { // backup information for re-creation @@ -332,6 +336,8 @@ IndexField.prototype = { this.domain.deleteConfiguration(this.searchEnabledConfigurationKey); if (this._defaultSearchField) this.domain.defaultSearchField = null; + + return this; }, reindexSync: function() { var name = this.name; @@ -369,6 +375,7 @@ IndexField.prototype = { source: this.columnName }); } + return this; }, exists: function() { @@ -376,11 +383,12 @@ IndexField.prototype = { }, upgradeToMultipleValuesSync: function() { - if (this.multipleValues) return; + if (this.multipleValues) return this; var values = this.domain.dumpSync(); this.deleteSync(); this.createSync(true); this.domain.loadSync(values); + return this; } }; -------------- next part -------------- HTML����������������������������... Download