src/create/add-collection.js
function getFields(collection) {

    var message = 'What fields should "' + collection + '" have?\n',
        config;

    config = {
        properties: {
            fields: {
                description: message.magenta +
                '   Comma-separated fieldname:fieldtype pairs (ex: id:index, username:username)\n'.grey,
                type: 'string',
                required: true,
                pattern: FIELDS_REGEXP
            }
        }
    };

    prompt.start();
    prompt.message = '   >> ';
    prompt.delimiter = '';

    return new Promise(function(resolve, reject) {
        prompt.get(config, function(err, result) {
            if (err) return reject(err);
            return resolve(result.fields);
        });
    }).then(function(input) {
        return (input.match(FIELDS_REGEXP) || []).reduce(function(prev, curr) {
            var parts = curr.split(':');
            prev[parts[0]] = parts[1].replace(/\+/g, '}~{'); // with "+" also support name={fistName}~{lastName} concatenations
            return prev;
        }, {});
    });
}
function getFields(collection) {

    var message = 'What fields should "' + collection + '" have?\n',
        config;

    config = {
        properties: {
            fields: {
                description: message.magenta +
                '   Comma-separated fieldname:fieldtype pairs (ex: id:index, username:username)\n'.grey,
                type: 'string',
                required: true,
                pattern: FIELDS_REGEXP
            }
        }
    };

    prompt.start();
    prompt.message = '   >> ';
    prompt.delimiter = '';

    return new Promise(function(resolve, reject) {
        prompt.get(config, function(err, result) {
            if (err) return reject(err);
            return resolve(result.fields);
        });
    }).then(function(input) {
        return (input.match(FIELDS_REGEXP) || []).reduce(function(prev, curr) {
            var parts = curr.split(':');
            prev[parts[0]] = parts[1].replace(/\+/g, '}~{'); // with "+" also support name={fistName}~{lastName} concatenations
            return prev;
        }, {});
    });
}
function getFields ( collection ) { var message = 'What fields should "' + collection + '" have?\n' , config ; config = { properties : { fields : { description : message . magenta + '   Comma-separated fieldname:fieldtype pairs (ex: id:index, username:username)\n' . grey , type : 'string' , required : true , pattern : FIELDS_REGEXP } } } ; prompt . start ( ) ; prompt . message = '   >> ' ; prompt . delimiter = '' ; return new Promise ( function ( resolve , reject ) { prompt . get ( config , function ( err , result ) { if ( err ) return reject ( err ) ; return resolve ( result . fields ) ; } ) ; } ) . then ( function ( input ) { return ( input . match ( FIELDS_REGEXP ) || [ ] ) . reduce ( function ( prev , curr ) { var parts = curr . split ( ':' ) ; prev [ parts [ 0 ] ] = parts [ 1 ] . replace ( / \+ / g , '}~{' ) ; // with "+" also support name={fistName}~{lastName} concatenations return prev ; } , { } ) ; } ) ; }
Prompt for collection fields.
@return {Promise}
Prompt for collection fields .