Navigation Menu

Skip to content

Commit

Permalink
Define IndexField#summary
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Aug 15, 2012
1 parent 42911a1 commit 2142681
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bin/gcs-configure-fields
Expand Up @@ -84,5 +84,5 @@ if (commandLine.options.delete) {
field.saveOptionsSync();

console.log('Updated 1 Index Field:');
console.log('%s %s %s (%s)', field.name, field.state, field.type, field.options);
console.log(field.summary);
}
3 changes: 1 addition & 2 deletions bin/gcs-describe-domain
Expand Up @@ -42,8 +42,7 @@ function report(domain) {
console.log('Fields:');
console.log('=======');
domain.indexFields.forEach(function(field) {
console.log('%s %s %s (%s)',
field.name, field.state, field.type, field.options);
console.log(field.summary);
});
console.log('======================');
}
Expand Down
5 changes: 5 additions & 0 deletions lib/database/index-field.js
Expand Up @@ -248,6 +248,11 @@ IndexField.prototype = {
return 'Active';
},

get summary() {
return this.name + ' ' + this.state + ' ' +
this.type + ' (' + this.options + ')';
},

get multipleValues() {
return !!this.column &&
this.column.flags.indexOf(nroonga.COLUMN_VECTOR) > -1;
Expand Down
12 changes: 12 additions & 0 deletions test/database-index-field.test.js
Expand Up @@ -156,6 +156,18 @@ suite('database', function() {
});
});

test('summary', function() {
var textField = new IndexField('name', domain).setType('text');
var uintField = new IndexField('age', domain).setType('uint');
var literalField = new IndexField('product', domain).setType('literal');
assert.deepEqual({ text: textField.summary,
uint: uintField.summary,
literal: literalField.summary },
{ text: 'name Active text (Search)',
uint: 'age Active uint (Facet Result)',
literal: 'product Active literal ()' });
});

suite('getting data from database', function() {
var temporaryDatabase;
var context;
Expand Down
6 changes: 2 additions & 4 deletions test/gcs-commands.test.js
Expand Up @@ -200,10 +200,8 @@ suite('gcs-describe-domain', function() {
'\n' +
'Fields:\n' +
'=======\n' +
ageField.name + ' ' + ageField.state + ' ' +
ageField.type + ' (' + ageField.options + ')\n' +
nameField.name + ' ' + nameField.state + ' ' +
nameField.type + ' (' + nameField.options + ')\n' +
ageField.summary\n' +
nameField.summary\n' +
'======================\n' });

done();
Expand Down

0 comments on commit 2142681

Please sign in to comment.