How to use the odata.metadata function in odata

To help you get started, we’ve selected a few odata 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 Azure / Azurite / lib / actions / table / QueryEntities.js View on Github external
_createResponsePayload(payload, tableName, accept, singleEntity) {
    let response = {};

    if (accept !== ODataMode.NONE) {
      response[
        "odata.metadata"
      ] = `http://127.0.0.1:10002/devstoreaccount1/$metadata#${tableName}`;
    }
    // case where we do not have an array
    if (singleEntity) {
      for (const item of payload) {
        response["PartitionKey"] = item.partitionKey;
        response["RowKey"] = item.rowKey;
        response = Object.assign({}, response, item.attribs(accept));
      }
    } else if (payload.length === 1) {
      response["PartitionKey"] = payload[0].partitionKey;
      response["RowKey"] = payload[0].rowKey;
      for (const attrib in payload[0].attribs(accept)) {
        response[attrib] = payload[0]._.attribs[attrib];
      }
github koltyakov / sp-rest-proxy / src / core / routers / restGet.ts View on Github external
.then((r) => {
        // Paged collections patch
        if (typeof r.body['odata.nextLink'] === 'string') {
          r.body['odata.nextLink'] = this.util.buildProxyEndpointUrl(r.body['odata.nextLink']);
        }
        if (r.body.d && typeof r.body.d.__next === 'string') {
          r.body.d.__next = this.util.buildProxyEndpointUrl(r.body.d.__next);
        }
        // OData patch to PnPjs chained requests work
        if (typeof r.body['odata.metadata'] === 'string') {
          r.body['odata.metadata'] = this.util.buildProxyEndpointUrl(r.body['odata.metadata']);
        }
        // OData patch to PnPjs URI resolver, Verbose mode
        if (r.body?.d?.__metadata?.uri) {
          r.body.d.__metadata.uri = this.util.buildProxyEndpointUrl(r.body.d.__metadata.uri);
        }
        return r;
      })
      .then((r) => this.transmitResponse(res, r))
github devnixs / ODataAngularResources / src / odataresources.js View on Github external
var promise = $http(httpConfig).then(function(response) {
                var data = response.data,
                  promise = value.$promise;

                if(data && angular.isNumber(data['@odata.count'])) {
                    data.count = data['@odata.count'];
                }

                if (data && (angular.isString(data['@odata.context']) || angular.isString(data['odata.metadata']) ) && data.value && angular.isArray(data.value)) {
                  var fullObject = data;
                  data = data.value;
                  for (var property in fullObject) {
                    if (property !== "value") {
                      value[property] = fullObject[property];
                    }
                  }
                }


                if (data) {
                  // Need to convert action.isArray to boolean in case it is undefined
                  // jshint -W018
                  if (angular.isArray(data) !== (!isSingleElement && !! action.isArray) && !forceSingleElement) {
                    throw $resourceMinErr('badcfg',
                      'Error in resource configuration for action `{0}`. Expected response to ' +
github arafato / azurite / lib / actions / table / QueryTable.js View on Github external
_createResponsePayload(payload, accept) {
        const response = {};
        if (accept !== ODataMode.NONE) {
            response['odata.metadata'] = `http://127.0.0.1:10002/devstoreaccount1/$metadata#Tables`;
        }
        response.value = [];
        let i = 0;
        for (const item of payload) {
            response.value.push(item.odata(accept))
            delete response.value[i]['odata.metadata'];
            ++i;
        }
        return response;
    }
}
github spatools / spatools / spa / data / dataset.ts View on Github external
.then(function (data) {
                if (data["odata.metadata"]) {
                    if (data["odata.count"])
                        count = data["odata.count"];

                    data = data.value;
                }
                else if (data.__count) {
                    count = data.__count;
                    data = data.results;
                }
                else if (!query) {
                    count = data.length;
                }

                return data;
            })
            .then(function (data) {
github arafato / azurite / lib / actions / table / QueryTable.js View on Github external
_createResponsePayload(payload, accept) {
        const response = {};
        if (accept !== ODataMode.NONE) {
            response['odata.metadata'] = `http://127.0.0.1:10002/devstoreaccount1/$metadata#Tables`;
        }
        response.value = [];
        let i = 0;
        for (const item of payload) {
            response.value.push(item.odata(accept))
            delete response.value[i]['odata.metadata'];
            ++i;
        }
        return response;
    }
}
github spatools / spatools / spa / data / remoteview.ts View on Github external
.then(function (data) {
                if (data["odata.metadata"]) {
                    if (data["odata.count"])
                        count = data["odata.count"];

                    data = data.value;
                }
                else if (data.__count) {
                    count = data.__count;
                    data = data.results;
                }
                else if (!query) {
                    count = data.length;
                }

                return data;
            })
            .then(function (data) {
github spatools / spatools / spa / data / foreignview.ts View on Github external
.done(function (data) {
                    var count = -1;

                    if (data["odata.metadata"]) {
                        if (data["odata.count"])
                            count = data["odata.count"];

                        data = data.value;
                    }

                    result = foreignSet.attachOrUpdate(data);

                    deferred.resolve(result, count === -1 ? data.length : count);
                })
                .fail(deferred.reject);

odata

o.js is a isomorphic Odata Javascript library to simplify the request of data. The main goal is to build a standalone, lightweight and easy to understand Odata lib.

MIT
Latest version published 4 months ago

Package Health Score

71 / 100
Full package analysis