How to use split-string - 4 common examples

To help you get started, we’ve selected a few split-string examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github scoutforpets / bookshelf-jsonapi-params / src / index.js View on Github external
qb.where(column, '>=', typeValue);
                                        }
                                    }
                                });
                            }
                        }
                        // If the value is an equality filter
                        else {
                            // If the key is in the like filter, ignore the filter
                            if (!_hasIn(filterValues.like, key)){
                                let [column, jsonColumn, dataType] = key.split(':');
                                // Remove all but the last table name, need to get number of dots
                                column = internals.formatRelation(internals.formatColumnNames([column])[0]);

                                if (!_isArray(value)){
                                    value = split(String(value), { keepQuotes: true, sep: ',' });
                                }

                                if (jsonColumn) {
                                    jsonFields.buildFilterWithType(qb, Bookshelf.knex, 'equal', value, column, jsonColumn, dataType);
                                }
                                else {
                                    internals.equalityFilter(qb, column, value);
                                }
                            }
                        }
                    });
                });
github scoutforpets / bookshelf-jsonapi-params / src / index.js View on Github external
column
                                                        })
                                                    );

                                                    // Change to orWhere after the first where
                                                    if (where === 'where'){
                                                        where = 'orWhere';
                                                    }
                                                });

                                                // If the key is in the top level filter, filter on orWhereIn
                                                if (_hasIn(filterValues, typeKey)){
                                                    // Determine if there are multiple filters to be applied
                                                    let equalityValue = filterValues[typeKey];
                                                    if (!_isArray(equalityValue)){
                                                        equalityValue = split(String(equalityValue), { keepQuotes: true, sep: ',' });
                                                    }

                                                    internals.equalityFilter(qbWhere, column, equalityValue, 'orWhere');
                                                }
                                            });
                                        }
github scoutforpets / bookshelf-jsonapi-params / src / index.js View on Github external
_forEach(filterTypeValues, (typeValue, typeKey) => {

                                    let [column, jsonColumn, dataType] = typeKey.split(':');
                                    // Remove all but the last table name, need to get number of dots
                                    column = internals.formatRelation(internals.formatColumnNames([column])[0]);

                                    // Determine if there are multiple filters to be applied
                                    let valueArray = split(String(typeValue), { keepQuotes: true, sep: ',' });

                                    if (jsonColumn) {
                                        // Pass in the an equality filter for the same column name as last parameter for OR filtering with `like` and `equals`
                                        let extraEqualityFilter = filterValues[typeKey];
                                        if (extraEqualityFilter) {
                                            extraEqualityFilter = split(String(extraEqualityFilter), { keepQuotes: true, sep: ',' });
                                        }
                                        jsonFields.buildFilterWithType(qb, Bookshelf.knex, key, valueArray, column, jsonColumn, dataType, extraEqualityFilter);
                                    }
                                    else {
                                        // Attach different query for each type
                                        if (key === 'like'){
                                            qb.where((qbWhere) => {

                                                let where = 'where';
                                                let textType = 'text';
                                                if (internals.client === 'mysql' || internals.client === 'mssql'){
                                                    textType = 'char';
                                                }
                                                _forEach(valueArray, (val) => {

                                                    let likeQuery = `LOWER(CAST(:column: AS ${textType})) like LOWER(:value)`;
github scoutforpets / bookshelf-jsonapi-params / src / index.js View on Github external
_forEach(filterTypeValues, (typeValue, typeKey) => {

                                    let [column, jsonColumn, dataType] = typeKey.split(':');
                                    // Remove all but the last table name, need to get number of dots
                                    column = internals.formatRelation(internals.formatColumnNames([column])[0]);

                                    // Determine if there are multiple filters to be applied
                                    let valueArray = split(String(typeValue), { keepQuotes: true, sep: ',' });

                                    if (jsonColumn) {
                                        // Pass in the an equality filter for the same column name as last parameter for OR filtering with `like` and `equals`
                                        let extraEqualityFilter = filterValues[typeKey];
                                        if (extraEqualityFilter) {
                                            extraEqualityFilter = split(String(extraEqualityFilter), { keepQuotes: true, sep: ',' });
                                        }
                                        jsonFields.buildFilterWithType(qb, Bookshelf.knex, key, valueArray, column, jsonColumn, dataType, extraEqualityFilter);
                                    }
                                    else {
                                        // Attach different query for each type
                                        if (key === 'like'){
                                            qb.where((qbWhere) => {

                                                let where = 'where';
                                                let textType = 'text';

split-string

Easy way to split a string on a given character unless it's quoted or escaped.

MIT
Latest version published 6 years ago

Package Health Score

71 / 100
Full package analysis

Popular split-string functions