How to use the @ember-data/model.attr function in @ember-data/model

To help you get started, we’ve selected a few @ember-data/model 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 jelhan / croodle / app / models / user.js View on Github external
/*
   * properties
   */
  // ISO 8601 date + time string
  creationDate: attr('date'),

  // user name
  name: attr('string'),

  // array of users selections
  // must be in same order as options property of poll
  selections: fragmentArray('selection'),

  // Croodle version user got created with
  version: attr('string', {
    encrypted: false
  })
});
github travis-ci / travis-web / app / models / request.js View on Github external
CLEAN: 'clean'
};

export default Model.extend({
  created_at: attr(),
  event_type: attr(),
  result: attr(),
  message: attr('string'),
  headCommit: attr(),
  baseCommit: attr(),
  branchName: attr('string'),
  pullRequestMergeable: attr('string'),
  tagName: attr('string'),
  pullRequest: attr('boolean'),
  pullRequestTitle: attr('string'),
  pullRequestNumber: attr('number'),
  config: attr(),
  raw_configs: attr(),
  uniqRawConfigs: uniqBy('raw_configs', 'source'),
  noYaml: empty('raw_configs'),
  repo: belongsTo('repo', { async: true }),
  commit: belongsTo('commit', { async: true }),

  // API models this as hasMany but serializers:request#normalize overrides it
  build: belongsTo('build', { async: true }),

  isAccepted: computed('result', 'build.id', function () {
    // For some reason some of the requests have a null result beside the fact that
    // the build was created. We need to look into it, but for now we can just assume
    // that if build was created, the request was accepted

    let result = this.result;
github travis-ci / travis-web / app / models / stage.js View on Github external
import Model, { attr, belongsTo } from '@ember-data/model';
import { computed } from '@ember/object';
import DurationCalculations from 'travis/mixins/duration-calculations';
import DurationAttributes from 'travis/mixins/duration-attributes';

export default Model.extend(DurationCalculations, DurationAttributes, {
  number: attr(),
  name: attr('string'),
  state: attr(),

  build: belongsTo('build', { async: true }),

  notStarted: computed('state', function () {
    let state = this.state;
    let waitingStates = ['queued', 'created', 'received'];
    return waitingStates.includes(state);
  }),
});
github travis-ci / travis-web / app / models / subscription.js View on Github external
github: 'GitHub Marketplace',
  manual: 'manual',
  stripe: 'Stripe'
};

export default Model.extend({
  api: service(),
  accounts: service(),

  source: attr(),
  status: attr(),
  validTo: attr(),
  permissions: attr(),
  organizationId: attr(),
  coupon: attr(),
  clientSecret: attr(),
  paymentIntent: attr(),

  billingInfo: belongsTo('billing-info', { async: false }),
  creditCardInfo: belongsTo('credit-card-info', { async: false }),
  invoices: hasMany('invoice'),
  owner: belongsTo('owner', { polymorphic: true }),
  plan: belongsTo(),

  isSubscribed: equal('status', 'subscribed'),
  isCanceled: equal('status', 'canceled'),
  isExpired: equal('status', 'expired'),
  isPending: equal('status', 'pending'),
  isIncomplete: equal('status', 'incomplete'),
  isStripe: equal('source', 'stripe'),
  isGithub: equal('source', 'github'),
  isManual: equal('source', 'manual'),
github NREL / api-umbrella / src / api-umbrella / admin-ui / app / models / api-user.js View on Github external
firstName: validator('presence', true),
  lastName: validator('presence', true),
  email: validator('presence', true),
});

export default Model.extend(Validations, {
  apiKey: attr(),
  apiKeyHidesAt: attr(),
  apiKeyPreview: attr(),
  firstName: attr(),
  lastName: attr(),
  email: attr(),
  emailVerified: attr(),
  website: attr(),
  useDescription: attr(),
  registrationSource: attr(),
  termsAndConditions: attr(),
  sendWelcomeEmail: attr(),
  throttleByIp: attr('boolean'),
  roles: attr(),
  enabled: attr('boolean'),
  createdAt: attr(),
  updatedAt: attr(),
  creator: attr(),
  updater: attr(),
  registrationIp: attr(),
  registrationUserAgent: attr(),
  registrationReferer: attr(),
  registrationOrigin: attr(),

  settings: belongsTo('api/settings', { async: false }),
github hashicorp / nomad / ui / app / models / job-version.js View on Github external
import Model from '@ember-data/model';
import { attr, belongsTo } from '@ember-data/model';

export default class JobVersion extends Model {
  @belongsTo('job') job;
  @attr('boolean') stable;
  @attr('date') submitTime;
  @attr('number') number;
  @attr() diff;

  revertTo() {
    return this.store.adapterFor('job-version').revertTo(this);
  }
}
github travis-ci / travis-web / app / models / invoice.js View on Github external
import Model, { attr, belongsTo } from '@ember-data/model';
import { computed } from '@ember/object';

export default Model.extend({
  createdAt: attr('date'),
  url: attr('string'),
  amountDue: attr('number'),

  subscription: belongsTo('subscription'),

  year: computed('createdAt', function () {
    return this.createdAt.getFullYear();
  })
});
github hashicorp / nomad / ui / app / models / network.js View on Github external
import { attr } from '@ember-data/model';
import Fragment from 'ember-data-model-fragments/fragment';
import { array } from 'ember-data-model-fragments/attributes';

export default class Network extends Fragment {
  @attr('string') device;
  @attr('string') cidr;
  @attr('string') ip;
  @attr('string') mode;
  @attr('number') mbits;
  @array() ports;
}
github travis-ci / travis-web / app / models / commit.js View on Github external
import Model, { attr, belongsTo } from '@ember-data/model';
import { computed } from '@ember/object';
import { inject as service } from '@ember/service';

export default Model.extend({
  sha: attr(),
  branch: attr(),
  message: attr(),
  compareUrl: attr(),
  authorName: attr(),
  authorEmail: attr(),
  committerName: attr(),
  committerEmail: attr(),
  committedAt: attr(),
  committerAvatarUrl: attr(),
  authorAvatarUrl: attr(),

  build: belongsTo('build'),

  externalLinks: service(),

  subject: computed('message', function () {
github hashicorp / vault / ui / app / models / database / role.js View on Github external
import Model, { attr } from '@ember-data/model';
import { computed } from '@ember/object';
import { alias } from '@ember/object/computed';
import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities';
import { expandAttributeMeta } from 'vault/utils/field-to-attrs';

export default Model.extend({
  idPrefix: 'role/',
  backend: attr('string', { readOnly: true }),
  name: attr('string', {
    label: 'Role name',
  }),
  database: attr('array', {
    label: '',
    editType: 'searchSelect',
    fallbackComponent: 'string-list',
    models: ['database/connection'],
    selectLimit: 1,
    onlyAllowExisting: true,
    subLabel: 'Database name',
    subText: 'The database for which credentials will be generated.',
  }),
  type: attr('string', {
    label: 'Type of role',
    noDefault: true,

@ember-data/model

A basic Ember implementation of a resource presentation layer for use with @ember-data/store

MIT
Latest version published 1 month ago

Package Health Score

88 / 100
Full package analysis