Registry / database / edge-sql

edge-sql

JSON →
library1.0.6jsnpmunverified

Edge-sql is an ADO.NET-based SQL compiler for Edge.js, enabling Node.js applications to access MS SQL, MySQL, and PostgreSQL databases via C#/CLR. As of v1.0.6, it supports .NET 4.6.2 (except PostgreSQL) and .NET Core/netstandard2.0, with optional environment variable or runtime connection strings. It automatically interprets SQL statement types (SELECT as data reader, UPDATE as non-query) and returns multiple result sets. Unlike pure JavaScript drivers, it bridges Node.js and .NET for scenarios where ADO.NET is preferred.

npm install edge-sql
INSTALL
IMPORT
SIG · EDGE-SQL
E
edge-sql
databasejavascriptv1.0.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

edge.func
✓ const edge = require('edge-js'); const getUsers = edge.func('sql', function () {/* ... */});
✗ const getUsers = require('edge-sql');
edge-sql is not imported directly; it's a compiler loaded by edge.func with 'sql' as the language parameter.
connectionString (env var)
✓ process.env.EDGE_SQL_CONNECTION_STRING = 'Data Source=...';
✗ const edge = require('edge-sql').setConnectionString('...');
Connection string is set via environment variable or passed as an option to edge.func; edge-sql does not export a setter.
Options object
✓ edge.func({ connectionString: '...', source: function () {/* SQL */}, db: 'MsSql' });
✗ edge.func('sql', { connectionString: '...' });
When passing options, use an object with source, connectionString, etc. The first parameter is the language ('sql') or an options object.

Shows how to query MS SQL via Edge.js with edge-sql, using an inline SQL statement and a callback.

const edge = require('edge-js'); const getProducts = edge.func('sql', function () {/* select top 5 * from Products */}); getProducts(null, function (error, result) { if (error) throw error; console.log(result); });
Debug
Known issues
gotchaSQL statements starting with 'select' are executed as ExecuteReaderAsync by default; use nonQuery option to force ExecuteNonQueryAsync for stored procedures without output parameters.
fix
Add nonQuery: true to options if you need to run a select statement as a non-query (e.g., function call).
affects: >=1.0
deprecatedThe original edge-sql by tjanczuk is deprecated; this fork (agracio/edge-sql) is the active version.
fix
Use the fork: npm install edge-sql (which installs agracio's version).
affects: all
gotchaPostgreSQL support is only available when using .NET Core; not supported on .NET 4.6.2.
fix
Ensure your Edge.js is running on .NET Core to use PostgreSQL database option.
affects: >=1.0
gotchaEnvironment variable EDGE_SQL_CONNECTION_STRING is read only once at initialization. Changing it later has no effect.
fix
Set the environment variable before calling edge.func for the first time, or pass connectionString as an option.
affects: >=1.0
gotchaGeometry/Geography types in MySQL and PostgreSQL must be converted manually using ST_AsText/ST_GeomFromText; edge-sql does not do automatic conversion.
fix
Wrap geometry columns with ST_AsText in SELECT and use ST_GeomFromText in INSERT/UPDATE.
affects: >=1.0
Errors
Common errors & fixes
Error: Cannot find module 'edge-sql'
The 'sql' compiler is not automatically discovered; edge-sql must be installed and required? Or the module path is wrong.
fix
Make sure edge-js and edge-sql are both installed: npm install edge-js edge-sql. The compiler is registered by edge-sql when required? Actually, edge-js picks it up from node_modules; if not, try: require('edge-sql');
Error: Connection string is not defined. Provide environment variable EDGE_SQL_CONNECTION_STRING or pass connectionString option.
No connection string provided via environment variable or options object.
fix
Set EDGE_SQL_CONNECTION_STRING environment variable or pass { connectionString: '...' } to edge.func.
Error: The type initializer for 'Edge.Sql' threw an exception.
ADO.NET provider not installed or .NET runtime mismatch (e.g., PostgreSQL on .NET 4.x).
fix
Ensure the appropriate .NET data provider is installed (e.g., System.Data.SqlClient for MS SQL, Npgsql for PostgreSQL). For PostgreSQL, use .NET Core.
Error: Sequence contains no matching element
Parameterized query expects named parameters but none provided, or parameter mismatch.
fix
Ensure parameters object keys match the parameter names in SQL (case-insensitive for MS SQL).
Upgrade
Version history
1.0.6latest on npm
Audit
Dependencies
edge-jsrequiredRequired runtime; edge-sql is a compiler that plugs into Edge.js to execute SQL via .NET.
Agent activity
13 hits · last 30 days
node
12
Resources
edge-sql — npm install edge-sql · libregistry