docs: function where() {
    /*jshint validthis:true */
    var self = (this instanceof QueryBuilder) ? this : new QueryBuilder();
  
    var args = mlutil.asArray.apply(null, arguments);
    var argLen = args.length;
    // TODO: if empty, clear the clause
  
    var parsedQuery = null;
    var fragmentScope = null;
    var queries = null;
  
    var i=0;
  
    var isQBE = false;
  
    var arg = (argLen > 0) ? args[0] : null;
    if (arg == null) {
      self.whereClause = {query: {queries: [and()]}};
    } else if (arg.$query != null) {
      if (argLen === 1) {
        isQBE = true;
        self.whereClause = arg;
      } else {
        throw new Error('A Query by Example (QBE) must be the only query');
      }
    } else {
      for (i=0; i < argLen; i++) {
        if (i > 0) {
          arg = args[i];
        }
        if ((parsedQuery == null) && arg instanceof ParsedDef) {
          parsedQuery = arg.parsedQuery;
          continue;
        }
        if ((fragmentScope == null) && arg instanceof FragmentScopeDef) {
          fragmentScope = arg['fragment-scope'];
          continue;
        }
        if (queries === null) {
          queries = [checkQuery(arg)];
        } else {
          queries.push(checkQuery(arg));
        }
      }
      var whereClause = {};
      if (queries !== null) {
        whereClause.query = {queries: queries};
      }
      if (parsedQuery != null) {
        whereClause.parsedQuery = parsedQuery;
      }
      if (fragmentScope != null) {
        whereClause['fragment-scope'] = fragmentScope;
      }
      self.whereClause = whereClause;
    }
  
    self.queryType   = (isQBE) ? 'qbe' : 'structured';
    self.queryFormat = 'json';
  
    return self;
  }