How to use the @ember-data/store.normalizeModelName function in @ember-data/store

To help you get started, we’ve selected a few @ember-data/store examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github emberjs / data / packages / model / addon / -private / has-many.js View on Github external
if (typeof type === 'object') {
    options = type;
    type = undefined;
  }

  assert(
    `The first argument to hasMany must be a string representing a model type key, not an instance of ${inspect(
      type
    )}. E.g., to define a relation to the Comment model, use hasMany('comment')`,
    typeof type === 'string' || typeof type === 'undefined'
  );

  options = options || {};

  if (typeof type === 'string') {
    type = normalizeModelName(type);
  }

  // Metadata about relationships is stored on the meta of
  // the relationship. This is used for introspection and
  // serialization. Note that `key` is populated lazily
  // the first time the CP is called.
  let meta = {
    type,
    options,
    isRelationship: true,
    kind: 'hasMany',
    name: 'Has Many',
    key: null,
  };

  return computed({
github emberjs / data / packages / serializer / addon / rest.js View on Github external
modelNameFromPayloadKey(key) {
    return singularize(normalizeModelName(key));
  },
github emberjs / data / packages / model / addon / -private / belongs-to.js View on Github external
function belongsTo(modelName, options) {
  let opts, userEnteredModelName;
  if (typeof modelName === 'object') {
    opts = modelName;
    userEnteredModelName = undefined;
  } else {
    opts = options;
    userEnteredModelName = modelName;
  }

  if (typeof userEnteredModelName === 'string') {
    userEnteredModelName = normalizeModelName(userEnteredModelName);
  }

  assert(
    'The first argument to belongsTo must be a string representing a model type key, not an instance of ' +
      inspect(userEnteredModelName) +
      ". E.g., to define a relation to the Person model, use belongsTo('person')",
    typeof userEnteredModelName === 'string' || typeof userEnteredModelName === 'undefined'
  );

  opts = opts || {};

  let meta = {
    type: userEnteredModelName,
    isRelationship: true,
    options: opts,
    kind: 'belongsTo',
github emberjs / data / packages / serializer / addon / rest.js View on Github external
isPrimaryType(store, modelName, primaryModelClass) {
    return normalizeModelName(modelName) === primaryModelClass.modelName;
  },
github emberjs / data / packages / serializer / addon / json-api.js View on Github external
modelNameFromPayloadKey(key) {
    return singularize(normalizeModelName(key));
  },
github emberjs / data / packages / serializer / addon / json.js View on Github external
modelNameFromPayloadKey(key) {
    return normalizeModelName(key);
  },