dist/bbn.js
/**
     * Converts the given object 'filter' to a valid format of condition.
     * 
     * The resulting format will comply with bbn.fn.compareConditions and also with 
     * bbn databases functions and complex filters applied to bbn-vue list components.
     *
     * @method   filterToConditions
     * @global
     * @example
     * ```javascript
     * bbn.fn.filterToConditions({num: 3});
     * // {
     * //   logic: "AND",
     * //   conditions: [{
     * //     field: "num",
     * //     operator: "=",
     * //     value: 3
     * //   }]
     * // }
     * ```
     * @example
     * ```javascript
     * bbn.fn.filterToConditions({num: 3}, '>');
     * // {
     * //   logic: "AND",
     * //   conditions: [{
     * //     field: "num",
     * //     operator: ">",
     * //     value: 3
     * //   }]
     * // }
     * ```
     * @memberof bbn.fn
     * @param    {Object} filter
     * @param    {String} operator
     * @returns  {Object} 
     */
Converts the given object 'filter' to a valid format of condition.

The resulting format will comply with bbn.fn.compareConditions and also with
bbn databases functions and complex filters applied to bbn-vue list components.


Converts the given object ' filter ' to a valid format of condition . The resulting format will comply with bbn . fn . compareConditions and also with bbn databases functions and complex filters applied to bbn - vue list components .
filterToConditions(filter, operator){
      if ( !bbn.fn.isObject(filter) ){
        throw new Error("Error in bbn.fn.filterToCondition: filter must be an object");
      }
      if ( !filter.conditions || !bbn.fn.isArray(filter.conditions) ){
        let tmp = [];
        bbn.fn.iterate(filter, (a, n) => {
          if ( bbn.fn.isObject(a) && (typeof a.conditions === 'object') ){
            tmp.push(bbn.fn.filterToConditions(a));
          }
          else{
            tmp.push({
              field: n,
              operator: operator || '=',
              value: a
            });
          }
        });
        filter = {
          conditions: tmp
        };
      }
      if ( !filter.logic ){
        filter.logic = 'AND';
      }
      return filter;
    }
filterToConditions ( filter , operator ) { if ( ! bbn . fn . isObject ( filter ) ) { throw new Error ( "Error in bbn.fn.filterToCondition: filter must be an object" ) ; } if ( ! filter . conditions || ! bbn . fn . isArray ( filter . conditions ) ) { let tmp = [ ] ; bbn . fn . iterate ( filter , ( a , n ) => { if ( bbn . fn . isObject ( a ) && ( typeof a . conditions === 'object' ) ) { tmp . push ( bbn . fn . filterToConditions ( a ) ) ; } else { tmp . push ( { field : n , operator : operator || '=' , value : a } ) ; } } ) ; filter = { conditions : tmp } ; } if ( ! filter . logic ) { filter . logic = 'AND' ; } return filter ; }
Converts the given object 'filter' to a valid format of condition.
Converts the given object ' filter ' to a valid format of condition .