npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@slackbyte/odata-sql-connect

v0.0.1

Published

A high speed OData V4.01 SQL Connector which provides functionality to convert the various types of OData segments into SQL query statements.

Downloads

9

Readme

odata-sql-connect

A highly versatile, fast and secured OData Version 4.01 SQL Connector which provides functionality to convert different types of OData segments into SQL query statements, that can be executed over an SQL database.

Potential Usecases

  • Create high speed, Odata 4.01 compliant data sharing APIs.
  • Can be used over most of the famous Databases like My SQL, My SQL server, Oracle and Postgres.

Special Unique features

  • Support for Odata V4.01 new features like 'in' operator.
  • Better and logical support for 'not' expression
  • By default, strict usage of bind variables or sql pramaters to avoid sql and odata injection.
  • Database specific SQL query functions gets generated.
  • Support for almost all the Filter operator.
  • Support for almost all the Query Functions.
  • Support for $orderby, $skip, $top, $count, $select.
  • Better erroring

Example

More examples can be found here

import { odataSql, DbTypes } from '@slackbyte/odata-sql-connect';

// Inpur str for Oracle, Postgres, MySql, MsSql
import { orderByStr, stringFuncs, topSkipObj } from '../tests/allTestInOutput';

const odataSqlPostgres = odataSql({ dbType: DbTypes.PostgreSql });
const { error: filterErr, where, parameters } = odataSqlPostgres.createFilter(stringFuncs);
if (filterErr) {
    console.error(filterErr.message);
} else {
    console.log(`Oracle/Postgres Example => Where clause: ${where}`);
    console.log(`Oracle/Postgres Example => Parameters/Bind Variables: ${Object.fromEntries(parameters)}`);
}

const { error: orderByErr, orderBy } = odataSqlPostgres.createOrderBy(orderByStr);
if (orderByErr) {
    console.error(orderByErr.message);
} else {
    console.log(`Oracle/Postgres Example => orderBy clause: ${orderBy}`);
}

const { error: topSkipErr, top, skip } = odataSqlPostgres.createTopSkip(topSkipObj);
if (topSkipErr) {
    console.error(topSkipErr.message);
} else {
    console.log(`Oracle/Postgres Example => Top: ${top}, Skip: ${skip}`);
}

// FIlter with named parameter prefix

const odataSqlMsSqlPrefix = odataSql({ dbType: DbTypes.MsSql, namedParamPrefix: 'value' });
const { error: filterPrefixErr, where: preWhere, parameters: preParameters } = odataSqlMsSqlPrefix.createFilter(stringFuncs);
if (filterPrefixErr) {
    console.error(filterPrefixErr.message);
} else {
    console.log(`MsSql Example => Where clause: ${preWhere}`);
    console.log(`MsSql Example => Parameters/Bind Variables: ${Object.fromEntries(preParameters)}`);
}

// With Raw parameters

const odataSqlPostgresRaw = odataSql({ dbType: DbTypes.PostgreSql, namedParamPrefix: 'var', useRawParameters: true });
const { error: filterRawErr, where: rawWhere, parameters: rawParameters } = odataSqlPostgresRaw.createFilter(stringFuncs);
if (filterRawErr) {
    console.error(filterRawErr.message);
} else {
    console.log(`Postgres Example => Where clause: ${rawWhere}`);
    const valArr = [...rawParameters.values()];
    console.log(`Postgres Example => Parameters/Bind Variables Values Array: ${valArr}`);
    console.log(`Postgres Example => Parameters/Bind Variables: ${Object.fromEntries(rawParameters)}`);
}

How to build

To run the connector in local, please clone the repository and follow the below steps:

npm install
npm run dev

To test and for test coverage:

npm test
npm run test:report

Supported Features

  • [x] $count
  • [x] $filter
    • [x] Comparison Operators
      • [x] eq
      • [x] ne
      • [x] lt
      • [x] le
      • [x] gt
      • [x] ge
      • [x] has
      • [x] in
    • [x] Logical Operators
      • [x] and
      • [x] or
      • [x] not
    • [ ] Arithmetic Operators
      • [x] add
      • [x] sub
      • [x] mul
      • [x] div
      • [ ] divby
      • [x] mod
    • [x] String Functions
      • [x] indexof
      • [x] contains
      • [x] endswith
      • [x] startswith
      • [x] length
      • [x] substring
      • [x] tolower
      • [x] toupper
      • [x] trim
      • [x] concat
    • [x] Date Functions
      • [x] year
      • [x] month
      • [x] day
      • [x] hour
      • [x] minute
      • [x] second
      • [ ] fractionalseconds
      • [x] date
      • [x] time
      • [ ] totaloffsetminutes
      • [x] now
      • [ ] mindatetime
      • [ ] maxdatetime
    • [x] Math Functions
      • [x] round
      • [x] floor
      • [x] ceiling
    • [ ] Type and conditional Functions
      • [ ] cast
      • [ ] isof
      • [ ] case
  • [x] $select
  • [x] $top
  • [x] $skip
  • [x] $orderby

CONTRIBUTING

I love your inputs! and I want to make your contribution to this project easy and transparent, whether it's:

  • Reporting a bug
  • Discussing the current state of the code
  • Submitting a fix
  • Proposing new features

Please raise a pull request. 😊

Made with love in INDIA. ❤️