From f1945120494ef5c6266531b61a1993e2d04f50e3 Mon Sep 17 00:00:00 2001 From: Amanuel Elhanan <69236638+elhananjair@users.noreply.github.com> Date: Fri, 30 Aug 2024 11:18:12 +0300 Subject: [PATCH 1/3] Update README.md A description of how to import the library. --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 421d19a0..2bdf2b63 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,11 @@ $ npm install postgres ``` ### Usage +There are two ways of importing the library in your code; either in ECMAScript or CommonJS module system + Create your `sql` database instance + +##### ECMAScript ```js // db.js import postgres from 'postgres' @@ -30,6 +34,13 @@ const sql = postgres({ /* options */ }) // will use psql environment variables export default sql ``` +##### CommonJS +```js +const postgres = require('postgres') + +const sql = postgres({ /* options */ }) // will use psql environment variables +export default SQL +``` Simply import for use elsewhere ```js From ae0dd2a672e498bbe071970e0c0277e2f1e6bfa3 Mon Sep 17 00:00:00 2001 From: Amanuel Elhanan <69236638+elhananjair@users.noreply.github.com> Date: Fri, 30 Aug 2024 13:58:29 +0300 Subject: [PATCH 2/3] Update README.md Update CommonJS export syntax --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2bdf2b63..a8bd9f89 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ export default sql const postgres = require('postgres') const sql = postgres({ /* options */ }) // will use psql environment variables -export default SQL +module.exports = sql ``` Simply import for use elsewhere From a77683ab685c98be30acffffc449b2a7f6793b7c Mon Sep 17 00:00:00 2001 From: Amanuel Elhanan <69236638+elhananjair@users.noreply.github.com> Date: Fri, 30 Aug 2024 14:09:46 +0300 Subject: [PATCH 3/3] Update README.md Added how to import in CommonJS --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a8bd9f89..cfe862db 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,8 @@ module.exports = sql Simply import for use elsewhere ```js // users.js -import sql from './db.js' +// const sql = require('./db.js') +import sql from './db.js' async function getUsersOver(age) { const users = await sql`