Giter VIP home page Giter VIP logo

suiteql's Introduction

SuiteQL

Node.js CI npm version downloads Coverage Status

NPM

Run SQL queries against NetSuite using SuiteQL through SuiteTalk Rest Webservices.

This class extends netsuite-rest

Installation

npm i suiteql

ESM or CommonJS?

This package is still compatible with CommonJS. But some dependencies, like got are now available only in ESM. This package will not be modified to support latest got versions to stay compatible with CommonJS. Instead you can use the native ESM module netsuite-api-client, which is a fork of the current package.

Quick Start

const suiteql = require('suiteql');
let suiteQL = new suiteql({
	consumer_key: process.env.consumer_key,
	consumer_secret_key: process.env.consumer_secret_key,
	token: process.env.token,
	token_secret: process.env.token_secret,
	realm: process.env.realm,
	base_url: process.env.base_url
});

query

query(string, limit = 1000, offset = 0)
  • string - Select query to run

  • limit - Limit number of rows, max is 1000

  • offset - Rows to start from

This method returns with the promise support, response will be in JSON format

Example

let transactions = await suiteQL.query("select id from transaction", 10, 0);

queryAll (Stream)

When working on large number of rows, stream is handy

queryAll(string, limit = 1000)
  • string - Select query to run

  • limit - Limit number of rows, max is 1000

Example

 let items = [];
    let st = suiteQL.queryAll(`
        select
            tranid, id from transaction
        where
            rownum <= 30
    `);

    st.on("data", (data) => {
      items.push(data);
    });

    st.on("end", () => {
        console.log("stream ended")
    });

suiteql's People

Contributors

dependabot[bot] avatar ehmad11 avatar julbrs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

frkr julbrs

suiteql's Issues

suggestion: Create typings

It would be nice to have TS typings available. This is a great package for simple query-based integrations, typings would make it more accessible.

suggestion: query string should sanitize tabs

hello again :)

just ran into a small issue, when having query string as template literal spanning multiple lines, can sometimes contain tab \t chars depending upon editor formatting.
for ease of use, can you update the regex to replace all \t with spaces to account for this?

otherwise the NetSuite REST API will throw error [{"detail":"Invalid content in the request body.","o:errorCode":"INVALID_CONTENT"}]

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.