<commit_before>import {
  queryExpression as oqe
} from 'orbit/query/expression';
import {
  addRecordOperation,
  replaceRecordOperation,
  removeRecordOperation,
  replaceAttributeOperation,
  addToHasManyOperation,
  removeFromHasManyOperation,
  replaceHasOneOperation,
  replaceHasManyOperation,
  replaceKeyOperation
} from 'orbit-common/lib/operations';
import MemorySource from 'orbit-common/memory-source';
import Transform from 'orbit/transform';
import Evented from 'orbit/evented';
import Cache from 'orbit-common/cache';
import TransformBuilder from 'orbit-common/transform/builder';
import TransformTracker from 'orbit-common/transform/tracker';

export default class Store {
  constructor(opts) {
    Evented.extend(this);
    this.schema = opts.schema;
    this._transformBuilder = new TransformBuilder();
    this._transformTracker = new TransformTracker();
    this.cache = new Cache(opts.schema);
  }

  /////////////////////////////////////////////////////////////////////////////
  // Query helpers
  /////////////////////////////////////////////////////////////////////////////

    return this.query(oqe('get', [type]))
      .then((records) => {
  findRecordsOfType(type) {
        if (records) {
          return Object.keys(records).map(k => records[k]);
        } else {
          return [];
        }
      });
  }

  findRecord(type, id) {
    return this.query(oqe('get', [type, id]));
  }

  /////////////////////////////////////////////////////////////////////////////
  // Transform helpers
  /////////////////////////////////////////////////////////////////////////////

  addRecord(record) {
    return this
      .update(t => t.addRecord(this.schema.normalize(record)))<commit_msg>Favor using record-aware query expressions.<commit_after>import {
  queryExpression as oqe
} from 'orbit/query/expression';
import {
  addRecordOperation,
  replaceRecordOperation,
  removeRecordOperation,
  replaceAttributeOperation,
  addToHasManyOperation,
  removeFromHasManyOperation,
  replaceHasOneOperation,
  replaceHasManyOperation,
  replaceKeyOperation
} from 'orbit-common/lib/operations';
import MemorySource from 'orbit-common/memory-source';
import Transform from 'orbit/transform';
import Evented from 'orbit/evented';
import Cache from 'orbit-common/cache';
import TransformBuilder from 'orbit-common/transform/builder';
import TransformTracker from 'orbit-common/transform/tracker';

export default class Store {
  constructor(opts) {
    Evented.extend(this);
    this.schema = opts.schema;
    this._transformBuilder = new TransformBuilder();
    this._transformTracker = new TransformTracker();
    this.cache = new Cache(opts.schema);
  }

  /////////////////////////////////////////////////////////////////////////////
  // Query helpers
  /////////////////////////////////////////////////////////////////////////////

  findRecordsOfType(type) {
    return this.query(oqe('recordsOfType', type))
      .then(records => {
        if (records) {
          return Object.keys(records).map(k => records[k]);
        } else {
          return [];
        }
      });
  }

  findRecord(type, id) {
    return this.query(oqe('record', type, id))
      .catch(e => undefined);
  }

  /////////////////////////////////////////////////////////////////////////////
  // Transform helpers
  /////////////////////////////////////////////////////////////////////////////

  addRecord(record) {
    return this
      .update(t => t.addRecord(this.schema.normalize(record)))
{'fraction_non_alphanumeric': 0.27114285714285713, 'fraction_numerical': 0.0, 'mean_word_length': 1.8348178137651823, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5184697', 'n_tokens_mistral': 878, 'n_tokens_neox': 839, 'n_words': 177}