How to use the ember-data.Adapter function in ember-data

To help you get started, we’ve selected a few ember-data 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 chancancode / hn-reader / app / adapters / article.js View on Github external
import Ember from 'ember';
import DS from 'ember-data';
import config from 'hn-reader/config/environment';

export default DS.Adapter.extend({

  proxy: config.APP.READIBILITY_PARSER_CORS_PROXY,
  host: config.APP.READIBILITY_PARSER_HOST,
  token: Ember.computed.alias('preferences.readibilityParserToken'),

  find(store, type, id) {
    return new Ember.RSVP.Promise( (resolve) => {

      var xhr = new XMLHttpRequest();

      xhr.open("GET", this.buildUrl(id), true);
      xhr.responseType = "json";

      xhr.onload = () => Ember.run(null, resolve, xhr.response);

      // We always "resolve" even when there is an error so we will remember not
github raido / ember-json-serializer-meta / tests / helpers / store.js View on Github external
if (typeof adapter !== 'string') {
    env.registry.register('adapter:-ember-data-test-custom', adapter);
    adapter = '-ember-data-test-custom';
  }

  for (let prop in options) {
    registry.register(`model:${Ember.String.dasherize(prop)}`, options[prop]);
  }

  registry.register('service:store', DS.Store.extend({
    adapter
  }));

  registry.optionsForType('serializer', { singleton: false });
  registry.optionsForType('adapter', { singleton: false });
  registry.register('adapter:-default', DS.Adapter);

  registry.register('serializer:-default', DS.JSONSerializer);
  registry.register('serializer:-rest', DS.RESTSerializer);

  registry.register('adapter:-rest', DS.RESTAdapter);

  registry.register('adapter:-json-api', DS.JSONAPIAdapter);
  registry.register('serializer:-json-api', DS.JSONAPISerializer);

  env.restSerializer = container.lookup('serializer:-rest');
  env.store = container.lookup('service:store');
  env.serializer = env.store.serializerFor('-default');
  env.adapter = env.store.get('defaultAdapter');

  return env;
}
github mdehoog / ember-data-has-many-query / tests / helpers / store.js View on Github external
if (typeof adapter !== 'string') {
    env.registry.register('adapter:-ember-data-test-custom', adapter);
    adapter = '-ember-data-test-custom';
  }

  for (let prop in options) {
    registry.register('model:' + dasherize(prop), options[prop]);
  }

  registry.register('service:store', DS.Store.extend({
    adapter: adapter
  }));

  registry.optionsForType('serializer', { singleton: false });
  registry.optionsForType('adapter', { singleton: false });
  registry.register('adapter:-default', DS.Adapter);

  registry.register('serializer:-default', DS.JSONSerializer);
  registry.register('serializer:-rest', DS.RESTSerializer);

  registry.register('adapter:-rest', DS.RESTAdapter);

  registry.register('adapter:-json-api', DS.JSONAPIAdapter);
  registry.register('serializer:-json-api', DS.JSONAPISerializer);

  env.restSerializer = container.lookup('serializer:-rest');
  env.store = container.lookup('service:store');
  env.serializer = env.store.serializerFor('-default');
  env.adapter = env.store.get('defaultAdapter');

  return env;
}
github ember-data / active-model-adapter / tests / helpers / setup-store.js View on Github external
if (typeof adapter !== 'string') {
    env.registry.register('adapter:-ember-data-test-custom', adapter);
    adapter = '-ember-data-test-custom';
  }

  for (var prop in options) {
    registry.register('model:' + Ember.String.dasherize(prop), options[prop]);
  }

  registry.register('store:main', DS.Store.extend({
    adapter: adapter
  }));

  registry.optionsForType('serializer', { singleton: false });
  registry.optionsForType('adapter', { singleton: false });
  registry.register('adapter:-default', DS.Adapter);

  registry.register('serializer:-default', DS.JSONSerializer);
  registry.register('serializer:-rest', DS.RESTSerializer);
  registry.register('serializer:-rest-new', DS.RESTSerializer.extend({ isNewSerializerAPI: true }));

  registry.register('adapter:-active-model', ActiveModelAdapter);
  registry.register('serializer:-active-model', ActiveModelSerializer);

  registry.register('adapter:-rest', DS.RESTAdapter);

  registry.injection('serializer', 'store', 'store:main');
  registry.register('transform:string', DS.StringTransform);
  registry.register('transform:number', DS.NumberTransform);
  registry.register('transform:date', DS.DateTransform);
  registry.register('transform:main', DS.Transform);
github nano-wallet-company / nano-wallet-desktop / app / application / adapter.js View on Github external
import DS from 'ember-data';
import { inject as service } from '@ember/service';
import { assign } from '@ember/polyfills';

export default DS.Adapter.extend({
  namespace: 'rpc',

  rpc: service(),
  ajax: service(),

  findRecord(store, type, id, snapshot) {
    return this.get('rpc').accountInfo(id).then((info) => {
      const data = this.serialize(snapshot, { includeId: true });
      return assign(data, info);
    });
  },

  createRecord(store, type, snapshot) {
    const data = this.serialize(snapshot, { includeId: true });
    switch (type.modelName) {
      case 'wallet':
github BlakeWilliams / ember-phoenix-adapter / addon / index.js View on Github external
import Ember from "ember";
import DS from "ember-data";
import {singularize, pluralize} from 'ember-inflector';

export default DS.Adapter.extend({
  defaultSerializer: "ams",

  addEvents: ["add"],
  updateEvents: ["update"],
  removeEvents: ["remove"],

  joinParams: {},

  init: function() {
    this.joinedChannels = {};
  },

  find: function(store, type, id) {
    return this._send(type.typeKey, "show", {id: id});
  },
github alphasights / ember-graphql-adapter / addon / adapter.js View on Github external
import { get } from '@ember/object';
import $ from 'jquery';
import { join } from '@ember/runloop';
import { Promise as EmberPromise } from 'rsvp';
import { camelize } from '@ember/string';
import DS from 'ember-data';
import Compiler from './compiler';
import request from 'ember-ajax/request';
import { pluralize } from 'ember-inflector';

export default DS.Adapter.extend({
  endpoint: null,
  httpMethod: 'GET',
  param: 'query',
  defaultSerializer: '-graphql',
  coalesceFindRequests: false,

  /**
    This function controls the normalization of all compound words.

    @method normalizeCase
    @param {String} string
    @return {String} string
  */
  normalizeCase: function(string) {
    return camelize(string);
  },