New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

batch-odata

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

batch-odata

Node services for odata

latest
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

batch-odata

Node module to provide OData batch services (currently supports v3 only)

Installation

npm install batch-odata --save

Use

Create an instance of the batch service. Create a batch; create a changeset; create and add requests to a batch or changeset; submit batch.

Requests and changesets are submitted in the order they are added.

Create an instance of the batch service:

var service = new odata.OData3BatchService();

Create a batch: createBatch(endpointUrl:string)

var batch = service.createBatch("https://YourBatchEndpoint.com/$batch");

Create a request: createRequest(method:string,url:string,data:{},contentId:string)

var request = service.createRequest("GET", "SomeEntity('EntityKey')", null, null);

Create a request w/headers:

var request = service.createRequest("GET", "SomeEntity('EntityKey')", null, null,{"Prefer":"return-no-content"});

Add headers to an existing request:

request.addHeaders({"Prefer":"return-no-content"});

Add the request to the batch:

batch.addRequest(request);

Create a changeset: createChangeset();

var changeset = service.createChangeset();

Add a request to a changeset:

changeset.addRequest(request);

Simple batch with one GET operation

var odata = require("batch-odata");
var service = new odata.OData3BatchService();
var batch = service.createBatch("https://YourBatchEndpoint.com/$batch");
var request = service.createRequest("GET", "SomeEntity('EntityKey')", null, null);
batch.addRequest(batch);
service.submitBatch(batch);
    .then(function (responses) {
        responses.forEach(function (response) {
            //Do something with response
        });
    };

Batch with changeset

var odata = require("batch-odata");
var service = new odata.OData3BatchService();
var batch = service.createBatch("https://YourBatchEndpoint.com/$batch");
var changeset = service.createChangeset();
var request = service.createRequest("POST", "YourEntity", {"foo":"bar"}, "1");
changeset.addRequest(request);
batch.addChangeset(changeset);
service.submitBatch(batch)
    .then(function (responses) {
        responses.forEach(function (response) {
            //Do something with response
        });
    };

Build for distribution

npm run dist

Compiles, builds to dist folder, increments version patch level and creates npm package file.

Development

npm run compile:dev

Cleans src and test folders of .js and .js.map files and recompiles.

Testing

npm test

Starts a single run of the test suite.

FAQs

Package last updated on 30 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts