<commit_before>import Ember from 'ember';
import registerDestroy from './-register-destroy';

const {
  computed,
  merge,
  assert,
  copy
} = Ember;

const matches = () => true;
const query = () => {};

const proxy = factory => opts => {
  opts = merge({ database: 'database', owner: [], document: [], matches, query }, opts);
  return computed(opts.database, function() {
    let { query, matches } = opts;
    let database = this.get(opts.database);
    let owner = copy(opts.owner);
    let document = copy(opts.document);
    assert(`Database not found for key ${opts.database}`, !!database);
    let internal = factory(database, this, { owner, document, matches, query });
    registerDestroy(this, () => internal.destroy());
    return internal.model(true);
  }).readOnly();
};

export const first     = proxy((database, ...args) => database._createInternalDocumentProxy(...args));
export const find      = proxy((database, ...args) => database._createInternalArrayProxy(...args));
export const paginated = proxy((database, ...args) => database._createInternalPaginatedProxy(...args));<commit_msg>add didLoad in base proxy computed prop<commit_after>import Ember from 'ember';
import registerDestroy from './-register-destroy';

const {
  computed,
  merge,
  assert,
  copy
} = Ember;

const matches = () => true;
const query = () => {};

const proxy = factory => opts => {
  opts = merge({ database: 'database', owner: [], document: [], matches, query }, opts);
  return computed(opts.database, function() {
    let { query, matches, didLoad } = opts;
    let database = this.get(opts.database);
    let owner = copy(opts.owner);
    let document = copy(opts.document);
    assert(`Database not found for key ${opts.database}`, !!database);
    let internal = factory(database, this, { owner, document, matches, query, didLoad });
    registerDestroy(this, () => internal.destroy());
    return internal.model(true);
  }).readOnly();
};

export const first     = proxy((database, ...args) => database._createInternalDocumentProxy(...args));
export const find      = proxy((database, ...args) => database._createInternalArrayProxy(...args));
export const paginated = proxy((database, ...args) => database._createInternalPaginatedProxy(...args));
{'fraction_non_alphanumeric': 0.1668145519077196, 'fraction_numerical': 0.0, 'mean_word_length': 4.136674259681094, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '3482640', 'n_tokens_mistral': 614, 'n_tokens_neox': 617, 'n_words': 179}