po

postgresql-orm

node to postgresql relational mapping library

Showing:

Popularity

Downloads/wk

3

GitHub Stars

3

Maintenance

Last Commit

7yrs ago

Contributors

0

Package

Dependencies

2

Size (min+gzip)

25.6KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Readme

npm install postgresql-orm --save

var ORM = require('postgresql-orm')

ORM.setup('postgres://<username>:<password>@<hostname>/<dbname>')

var userEntityDefinition = {
    name: 'users', // will match table with name 'users'
    attributes: {
        email: {
            type: 'character varying',
            unique: true
        },
        firstName: {
            type: 'character varying'
        },
        lastName: {
            type: 'character varying'
        },
        createdDate: {
            type: 'timestamp with time zone'
        }
    }
}

var User = ORM.define(userEntityDefinition)

User.dropTable(function(err) {
    // existing table dropped
})

User.createTable(function(err) {
    // table created
})

// save or update, depending on the presence of an 'id' attribute
User.save({firstName: 'John'}, function(err, savedEntity) {
    // do something
    savedEntity.id
})

User.create({firstName: 'John'}, function(err, createdEntity) {
    // do smthg
})

User.update({id: 123, lastName: 'Doe'}, function(err, updatedEntity) {
    // do smthg
})

User.load({id: 123}, function(err, loadedEntity) {
    // do smthg
})

Data Types

The data types available are those available in postgresql

notes

  • for each table, an auto-generated type column named id is required
  • attributes starting with an underscore are reserved
  • camel case attributes are transformed into snake case.
    • For example attributeName will map to column attribute_name
    • the behaviour is undefined if there are 2 attributes attributeName and attribute_name for one entity type as the resulting column names are the same.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100

Alternatives

wetlandA Node.js ORM, mapping-based. Works with MySQL, PostgreSQL, SQLite and more.
User Rating
5.0/ 5
1
Top Feedback
N/A
GitHub Stars
259
Weekly Downloads
29
bookshelfA simple Node.js ORM for PostgreSQL, MySQL and SQLite3 built on top of Knex.js
User Rating
3.8/ 5
4
Top Feedback
N/A
GitHub Stars
6K
Weekly Downloads
95K
objectionAn SQL-friendly ORM for Node.js
User Rating
3.3/ 5
3
Top Feedback
3Great Documentation
2Easy to Use
1Performant
GitHub Stars
6K
Weekly Downloads
105K
jug
jugglingdbMulti-database ORM for nodejs: redis, mongodb, mysql, sqlite3, postgresql, arango, in-memory...
User Rating
4.5/ 5
2
Top Feedback
1Great Documentation
1Highly Customizable
GitHub Stars
2K
Weekly Downloads
1K
typeormORM for TypeScript and JavaScript (ES7, ES6, ES5). Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.
User Rating
4.4/ 5
73
Top Feedback
11Easy to Use
11Poor Documentation
6Performant
GitHub Stars
26K
Weekly Downloads
779K
See 23 Alternatives