sedentary-pg
v0.1.3
Published
The ORM which never needs to migrate - PostgreSQL
Maintainers
Readme
sedentary-pg
under development
Description
The PostgreSQL specialized package of Sedentary.
Other DB engines: MySQL and SQLite are in todo but not yet planned.
Usage
import { SedentaryPG } from "sedentary-pg";
const db = new SedentaryPG({ database: "db", user: "user", password: "pass" });
const Items = db.model("Item", {
num: db.Int(),
str: db.VarChar({ size: 30 })
});
(async function () {
await db.connect();
const item = new Items();
item.num = 0;
item.str = "0";
await item.save();
const records = await Items.load({});
console.log(records); // [{ id: 1, num: 0, str: "0" }]
})();With TypeScript the instance can be typed using Entry<typeof Model>:
import { Entry, SedentaryPG } from "sedentary-pg";
const db = new SedentaryPG({ database: "db", user: "user", password: "pass" });
const Items = db.model("Item", { num: db.Int(), str: db.VarChar({ size: 30 }) });
type Item = Entry<typeof Items>;
const item: Item = new Items();
item.num = 0;
item.str = "0";Installation
With npm:
$ npm install --save sedentary-pgDocumentation
The full documentation is on sedentary.readthedocs.io.
Compatibility
Requires:
- Node.js: v20
- TypeScript: v5.7 (or none if used in a JavaScript project).
- PostgreSQL: v15
The package is tested under all version combinations of Node.js currently supported accordingly to Node.js Release and of PostgreSQL currently supported accordingly to PostgreSQL Versioning.
To work with the package under Windows, bash.exe can be configured as the script-shell.
> npm config set script-shell bash.exeLicense
Bugs
Bugs and inconsistencies can be reported @github.
Donating
Satoshis can be donated to this bitcoin address if the package is found useful:
1Md9WFAHrXTb3yPBwQWmUfv2RmzrtbHioB
