0.1.6 • Published 9 months ago

@n123al/oraclesql v0.1.6

Weekly downloads
17
License
MIT
Repository
github
Last release
9 months ago

Connect to an Oracle-SQL server and run queries using a simple API

A simple way to run SQL queries using Async/Await and Promises. This is not an ORM.
It uses node-mssql under the hood

Installation

npm install @n123al/oraclesql

initialization

import { SqlConfig, sqlInit } from '@n123al/oraclesql';
const sqlConfig: SqlConfig = {
    user: 'sa',
    password: 'password',
    server: 'localhost',
    database: 'AdventureWorks'
};
sqlInit(sqlConfig);

Usage

The first parameter is the SQL query to execute. Use @P1, @P2 for parameter values. the rest parameters are the values for the parameters (The first one will replace @P1, the second will replace @P2 and so on)

import { sql } from '@n123al/oraclesql';
sql
    .query('SELECT * FROM USERS WHERE name like @P1 AND isActive = @P2', 'John%', true)
    .then(data => console.log(data))
    .catch(error => console.error(error));

using Async / Await

try {
    const data = await sql.query('SELECT * FROM USERS WHERE name like @P1 AND isActive = @P2', 'John%', true);
} catch (error) {
    console.log(error);
}

Methods

  • sql.query (alias: sql.q): Executes query and returns an array with the results. Can be used for any query types
  • sql.queryOne (alias: sql.1): Executes the query and returns the first record, or null if there are no records
  • sql.insertReturnIdentity (alias: sql.ii): Can be used for INSERT. It will return the identity of the inserted record (i.e. SCOPE_IDENTITY()) or null
0.0.17

9 months ago

0.0.1-6.1

9 months ago

0.1.2

9 months ago

0.1.1

9 months ago

0.1.4

9 months ago

0.1.3

9 months ago

0.1.6

9 months ago

0.1.5

9 months ago

0.0.16

5 years ago

0.0.1-5.1

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago