message: Support for query with multiple expressions in local-storage source
diff: @@ -9,7 +9,7 @@ import Orbit, {
  syncable,
  Syncable,
  Query,
  - QueryOrExpression,
  + QueryOrExpressions,
  Source,
  SourceSettings,
  Transform,
  @@ -19,6 +19,7 @@ import Orbit, {
  RecordOperation,
  UpdateRecordOperation
  } from '@orbit/data';
  +import { QueryResultData } from '@orbit/record-cache';
  import { supportsLocalStorage } from './lib/local-storage';
  import LocalStorageCache, { LocalStorageCacheSettings } from './cache';
  @@ -45,7 +46,7 @@ export default class LocalStorageSource extends Source
  // Pullable interface stubs
  pull: (
  - queryOrExpression: QueryOrExpression,
  + queryOrExpressions: QueryOrExpressions,
  options?: object,
  id?: string
  ) => Promise<Transform[]>;
  @@ -142,28 +143,38 @@ export default class LocalStorageSource extends Source
  const results = this._cache.query(query);
  - if (Array.isArray(results)) {
  - operations = results.map(r => {
  + if (query.expressions.length === 1) {
  + operations = this._operationsFromQueryResult(results);
  + } else {
  + for (let result of results as QueryResultData[]) {
  + operations.push(...this._operationsFromQueryResult(result));
  + }
  + }
  +
  + const transforms = [buildTransform(operations)];
  +
  + await this.transformed(transforms);
  +
  + return transforms;
  + }
  +
  + _operationsFromQueryResult(result: Record | Record[]): Operation[] {
  + if (Array.isArray(result)) {
  + return result.map(r => {
  return {
  op: 'updateRecord',
  record: r
  };
  });
  - } else if (results) {
  - operations = [
  + } else if (result) {
  + return [
  {
  op: 'updateRecord',
  - record: results
  + record: result
  } as UpdateRecordOperation
  ];
  } else {
  - operations = [];
  + return [];
  }
  -
  - const transforms = [buildTransform(operations)];
  -
  - await this.transformed(transforms);
  -
  - return transforms;
  }
  }
  