{"id":16221595,"url":"https://github.com/leomedina/lightweight-pg-orm","last_synced_at":"2026-04-30T20:33:09.556Z","repository":{"id":112340476,"uuid":"285368062","full_name":"Leomedina/lightweight-pg-orm","owner":"Leomedina","description":"Open-sourced Lightweight npm package that helps you manage your PostgreSQL database using Node and Express. ","archived":false,"fork":false,"pushed_at":"2020-09-22T21:31:53.000Z","size":19,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-08T00:44:09.013Z","etag":null,"topics":["database","expressjs","javascript","nodejs","postgresql-database"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/lightweight-pg-orm","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Leomedina.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-05T18:07:51.000Z","updated_at":"2021-03-25T22:40:07.000Z","dependencies_parsed_at":"2023-05-03T08:03:37.116Z","dependency_job_id":null,"html_url":"https://github.com/Leomedina/lightweight-pg-orm","commit_stats":null,"previous_names":["leomedina/postgresql-lightweight-orm"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leomedina%2Flightweight-pg-orm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leomedina%2Flightweight-pg-orm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leomedina%2Flightweight-pg-orm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leomedina%2Flightweight-pg-orm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Leomedina","download_url":"https://codeload.github.com/Leomedina/lightweight-pg-orm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247755570,"owners_count":20990622,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","expressjs","javascript","nodejs","postgresql-database"],"created_at":"2024-10-10T12:09:03.049Z","updated_at":"2026-04-30T20:33:09.523Z","avatar_url":"https://github.com/Leomedina.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lightweight-pg-orm\n\nlightweight-pg-orm is built on top of pg, Node, and Express to help you easily create CRUD functions on your PostgreSQL database.\n\n## Installation\n\nUse [npm](https://www.npmjs.com/get-npm) to install.\n\n```bash\nnpm install lightweight-pg-orm\n```\n\n## Usage\nThis is best used on your Express routes. \n\n```javascript\nconst express = require(\"express\");\nconst Model = require(\"lightweight-pg-orm\");\n\nconst app = express();\n\nconst company = new Model(\"companies\", \"id\", [\"id\",\n  \"name\",\n  \"num_employees\",\n  \"description\",\n  \"logo_url\"]\n);\n\napp.get(\"/\", async function (req, res, next) {\n  try {\n    const results = await company.findAll(req.query);\n    return res.status(200).json({ \"companies\": results });\n  } catch (error) {\n    return next(error);\n  };\n});\n```\n\nApp.js must include a global variable for the root directory. Example below\n```javascript\nglobal.__basedir = __dirname;\n\nconst express = require('express');\nconst app = express();\n\n/** Routes */\napp.get('/', function (req, res, next) {\n  return res.status(200).json({\n    'status': 200,\n    'item': \"This is the homepage, nothing to see here.\",\n  })\n});\n\n/** 404 Error Handler */\napp.use(function (req, res, next) {\n  const error = new ExpressError('Page Not Found', 404);\n  return next(error);\n});\n\n/** Error Handler */\napp.use(function (err, req, res, next) {\n  res.status = err.status || 500;\n\n  return res.json({\n    status: res.status,\n    message: err.message\n  });\n});\n\nmodule.exports = app;\n```\n\n## BUGS\n\u003cstrong\u003eSQL-Injections:\u003c/strong\u003e Currently, we are handling SQL-injections on external requests but they are not handled when you create a model/table class.\n\n## Versions\n\n(live) 0.5.1 - First working version\n\n(TBD) 1.0.0 - Will better organize the code and handle SQL-injections when creating the classes.\n\n## Methods \n\n\u003cstrong\u003eClass Methods (Use these):\u003c/strong\u003e\n\n-\u003e get: retrieves single item from database.\n\n-\u003e findAll: retrieves all items from database or items matching query.\n\n-\u003e create: Creates a new item in the database.\n\n-\u003e update: Updates item in the database.\n\n-\u003e delete: Deletes item in the database.\n\n\u003cstrong\u003eHelper functions:\u003c/strong\u003e\n\n-\u003e WhereExpressions: creates where expressions depending on query passed.\n\n-\u003e createquery: creates SQL queries.\n\n-\u003e partialupdatequery: creates queries for update\n\n## Contributing\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make sure to update tests as appropriate.\n\n## Errors and bugs\nIf something is not behaving intuitively, it is a bug and should be reported. Report it here by creating an issue: https://github.com/Leomedina/lightweight-pg-orm/issues.\n\nHelp me fix the problem as quickly as possible by following Mozilla's guidelines for reporting bugs.\n## License\n[MIT](https://choosealicense.com/licenses/mit/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleomedina%2Flightweight-pg-orm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleomedina%2Flightweight-pg-orm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleomedina%2Flightweight-pg-orm/lists"}