Navigation Menu

Skip to content

Commit

Permalink
Check field existence before run
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Aug 3, 2012
1 parent 301c371 commit de66e50
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions bin/cs-configure-fields
Expand Up @@ -40,17 +40,25 @@ if (!program.name) {
console.log('You must specify the field name.');
return false;
}
if (!program.type) {
console.log('You must specify the field type.');
return false;
}

var field = domain.getIndexField(program.name);

if (program.delete) {
if (!field.exists()) {
console.log('You must specify an existing field.');
return false;
}
field.deleteSync();
console.log('Updated 1 Index Field:');
} else {
if (!program.type) {
console.log('You must specify the field type.');
return false;
}
if (field.exists()) {
console.log('You must specify not-existing field name.');
return false;
}
field.type = program.type;
field.createSync();
console.log('Updated 1 Index Field:');
Expand Down

0 comments on commit de66e50

Please sign in to comment.