{"repo":"mojolicious/pg.js","free":true,"listed":false,"github":"https://github.com/mojolicious/pg.js","clone":"git clone https://github.com/mojolicious/pg.js.git","description":"mojo.js :heart: PostgreSQL","language":"JavaScript","stars":16,"topics":["mojojs","postgresql"],"license":"MIT","category":"databases-storage","readme_excerpt":"A tiny wrapper around pg that makes PostgreSQL a lot of fun to use. Written in TypeScript. Tagged template literals are used everywhere to protect from SQL injection attacks and to make syntax highlighting easy. Examples This distribution also contains a great example you can use for inspiration. The well-structured blog application will show you how to apply the MVC design pattern in practice. TypeScript TypeScript is fully supported, just pass along a type with your query. This works for all query methods. All APIs are designed to be compatible with explicit resource management. And with TypeScript you can already use the feature in production. SQL building For easier SQL query building with partials, there are also pg.sql and db.sql tagged template literals (provided by @mojojs/sql). They can be used recursively to build complex queries securely. But if you need a little more control over the generated SQL query, you can of course also bypass safety features with the tagged template literals pg.sqlUnsafe and db.sqlUnsafe . But make sure to use methods like pg.escapeLiteral() to escape unsafe values yourself. And if you want to do complex things like reusing the same placeholder in multiple places, there is also pg.rawQuery() and db.rawQuery() available. Transactions It's best to use try / finally blocks whenever you dequeue a connection with pg.db() , to ensure efficient resource management. The tx.rollback() call does nothing if tx.commit() has been called first. Migratio","default_branch":null,"files":null,"tree":[],"storefront":"/r/mojolicious","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/mojolicious/pg.js/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}