How to use the js-data.DSUtils function in js-data

To help you get started, we’ve selected a few js-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 js-data / js-data-examples / server / sql / app / container.js View on Github external
container.register('DS', function (Promise, container, sqlAdapter, messageService) {
  var JSData = require('js-data');
  JSData.DSUtils.Promise = Promise;
  var store = new JSData.DS({
    cacheResponse: false,
    bypassCache: true,

    // Important: If your relationships stop working, you might
    // have deleted this.
    linkRelations: false,

    // Because
    upsert: false,

    // Don't really need this stuff on the server, so let's improve
    // performance and disable these features
    notify: false,
    keepChangeHistory: false,
    resetHistoryOnInject: false,
github microsoft / projection-grid / demos / vnext / data-source / jsdata / js-data-resource.js View on Github external
var _ = require('underscore');
var JSData = require('js-data');
var DSHttpAdapter = require('js-data-http');

JSData.DSUtils.Promise = require('bluebird');

var store = new JSData.DS();
store.registerAdapter('http', new DSHttpAdapter({
  basePath: 'http://services.odata.org/V4/Northwind/Northwind.svc/',
  deserialize: function (definition, response) {
    return response.data.value;
  },
  queryTransform: function (definition, params) {
    var query = {};

    _.has(params, 'offset') && (query.$skip = params.offset);
    _.has(params, 'limit') && (query.$top = params.limit);
    _.has(params, 'orderBy') && (query.$orderby = params.orderBy.map(function (item) {
      return item[0] + ' ' + item[1].toLowerCase();
    }).join(','));
github microsoft / projection-grid / spec / integrated / data / js-data-source.js View on Github external
import _ from 'underscore';
import JSData from 'js-data';
import DSHttpAdapter from 'js-data-http';

JSData.DSUtils.Promise = require('bluebird');
let store = new JSData.DS();

store.registerAdapter('http', new DSHttpAdapter({
  basePath: 'https://services.odata.org/V4/Northwind/Northwind.svc/',
  deserialize: (definition, response) => {
    return response.data.value;
  },
  queryTransform: (definition, params) => {
    let query = {};

    _.has(params, 'offset') && (query.$skip = params.offset);
    _.has(params, 'limit') && (query.$top = params.limit);
    _.has(params, 'orderBy') && (query.$orderby = params.orderBy.map((item) => {
      return item[0] + ' ' + item[1].toLowerCase();
    }).join(','));
github microsoft / projection-grid / demos / factory / js-data-resource.js View on Github external
findAll(definition, params, options) {
    let totalCount = 0;

    options.afterFindAll = (resource, data) => {
      totalCount = data['@odata.count'];
      return data.value;
    };
    options.afterInject = (resource, instances) => {
      Object.defineProperty(instances, 'totalCount', { value: totalCount });
    };

    return super.findAll(definition, params, options);
  }
}

JSData.DSUtils.Promise = require('bluebird');

var store = new JSData.DS();
store.registerAdapter('odata', new ODataAdapter({
  basePath: 'http://services.odata.org/V4/Northwind/Northwind.svc/',
}), { default: true });

module.exports = store.defineResource({
  name: 'Customers',
  idAttribute: 'CustomerID',
});