holdfenytolvaj / pogi Goto Github PK
View Code? Open in Web Editor NEWJavascript library for PostgreSQL and node.js
License: MIT License
Javascript library for PostgreSQL and node.js
License: MIT License
I'm sorry, but I am window shopping for ORM like library, and if it is not mentinoned, I usually ask, how to implement middleware.
My batteries included orm like product would be performant and include magic for updating records with inserted_at, updated_at and deleted_at. Also, all queries would know to ignore deleted_at IS NOT NULL records, when not specified (flag withDeleted = true etc.)
How easy is it to implement in pogi?
From studying the code, I just found out that PgDb
has a close()
method, which is indispensable in integration tests.
Please document it on https://pogi.readthedocs.io/en/latest/API/PgDb/.
Hello,
First I wanted to thank you for that amazing library.
One thing that I noticed, which seems not to be documented, is that transactionBegin returns PgDb instance which has empty object in tables property which is confusing.
hi! awesome library, thanks!
Is there a possiblity to automatically camelize object keys? Or an easy way to patch find, to do it myself?
Hello,
first: I really like your work. This is a really nice library without all the orm magic and abstraction layers.
problem: when I try to execute an initialization query (table create script) on an empty database, I got an error because the database is already queried during connect() but is empty.
Is there any way to work around this connection startup queries?
best regards
debug: [QUERY] SELECT current_schemas(false)
(node:23208) UnhandledPromiseRejectionWarning: Error: No readable schema found
Hi! This library looks cool.
I'm just trying to use it for the first time, and according to the documentation (see here: https://pogi.readthedocs.io/en/latest/connection/ ) you can set the max
property in the connection options, which looks like the max number of clients in the connection pool, however this max property is not present in the ConnectionOptions interface (neither in the linked document nor in the Connections options interface definition here:
Line 20 in 2fc9985
And of course, my ts compiler complains about this. Is this missing by purpose?
A recent update to PgDb.js that fixes #14 adds a requirement for module extsprintf, but Pogi's install does not install it. That makes Pogi except my app. I suspect this is cruft from a debug session.
Additionally, PgDb.js emits a query's text (prefaced with 'GGG'). I suspect that, too, is not intended, outside the context of a logger being enabled.
For my daily work, it would be very nice to have an option to define read replicas.
A possible way can be to add a flag to the query execution, to mark a query as read-only, so it is not needed to have a high amount of logic for this feature. On the other hand side, the developer is able to decide what queries to route to the replica.
Hi, i wanna use pre-generated interface without typescript in my project. It possible?
Is it possible to use Pgi with cockroachDB. I am getting this error pg_trigger" does not exist.
pgDb.js requires tslib, although it's missing in package.json.
Error: Cannot find module 'tslib'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/app/node_modules/pogi/lib/pgDb.js:4:17)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
Hi There! I really love Pogi, it seems to be the best all around tool.
But, I'm trying to import the PgDb class into a TS file to create a connection:
import { PgDb } from 'pogi';
// set up & connect to postgres db
const dbConfig = {
host: process.env.DB_URL,
port: process.env.DB_PORT,
database: process.env.DB_NAME,
user: process.env.DB_USER,
password: process.env.DB_PW,
max: 10,
idleTimeoutMillis: 10000,
poolSize: 10
};
export let connect = async () => {
return await PgDb.connect(dbConfig);
}
And am receiving the follow compilation error:
Node] /Users/Tyler/Projects/news-api/node_modules/pogi/lib/pgDb.js:69
[Node] constructor(pgdb = {}) {
[Node] ^
[Node]
[Node] SyntaxError: Unexpected token =
Am I not able to import the PgDb class into a typescript file? I'm currently running node v5.6.0 & npm v5.0.3, if that helps.
Side question: I see a lot of your examples use the await
keyword outside of an async function. Is that intentional? Usually (at least with TS), that keyword needs to be used inside of an async function.
Thanks for the help!
My app has begin to throw an exception in pgDb.js during connect() despite no changes to code, process, or data. I believe the addition of a new schema to the EDB variant of the PostgresSQL 9.6 database has surfaced this behavior. The new schema is not related to the app; the role for the app's schema has no access to the new schema. My guess is that the query that finds "special field types" unnecessarily reveals schema names it does not need.
I do not know whether to consider this a design issue in Pogi, or a problem in the way I use it. The first few lines in my app are:
(async () => {
const db = await PgDb.connect({connectionString: "postgres://app_media@<host>:<port>/<db>"});
const quotedFaculty = await db.query(assets.selectAppearingFacultyLastYear);
...
})();
My intellectual problem is that this behavior would affect any app using a database with more than one user-type schema. So, I look forward to another analysis -- because I don't trust mine. ;-)
Hi,
When using pogi with a postgres user which has rather limited access rights, I get a problem in pgDb.ts, in the initFieldTypes() function.
The error I get is "Cannot read property 'fieldTypes' of undefined".
If I change this:
...
for (let r of specialTypeFields.rows) {
this.schemas[r.schema_name][r.table_name].fieldTypes[r.column_name] =
([3802, 114].indexOf(r.typid) > -1) ? FieldType.JSON :
([3614].indexOf(r.typid) > -1) ? FieldType.TSVECTOR :
([1082, 1083, 1114, 1184, 1266].indexOf(r.typid) > -1) ? FieldType.TIME :
FieldType.ARRAY;
...
into something like:
...
for (let r of specialTypeFields.rows) {
if(this.schemas[r.schema_name][r.table_name]) {
this.schemas[r.schema_name][r.table_name].fieldTypes[r.column_name] =
([3802, 114].indexOf(r.typid) > -1) ? FieldType.JSON :
([3614].indexOf(r.typid) > -1) ? FieldType.TSVECTOR :
([1082, 1083, 1114, 1184, 1266].indexOf(r.typid) > -1) ? FieldType.TIME :
FieldType.ARRAY;
}
...
ie inserting an if test to check if we actually have the table metadata, pogi seems to work ok also in my case with limited postgres privileges.
Hello,
I'm trying to use your great library together with Meteor, but currently Meteor has an issue that it cannot use ES2015 compiled js files from NPM. And I see that you compile your ts files into ES2015 js files. My question is, can you consider maybe compiling your package to ES5 compatible js files, or maybe do you know a way to use your package together with Meteor? I have seen hints in your blog post that you were/are using also Meteor.
Thank you
We're not using Pogi as the only library for connecting to our database, and for that we instantiate a pg.Pool
ourselves which we share between different services. It would be dope if Pogi could be instantiated to use such a pre-existing pool, instead of getting passed connection options only and managing the pool (or actually, all the pools for each connection string).
If you still want to pool the PgDB
instances, I guess it should be possible to get the (undocumented) .options
from the Pool
instance to create your connection string key.
Hi I'm looking into upsert support for pogi.
API wise it could be either a seperate method like upsert
and upsertAndGet
or just an additional parameter on the existing insert
and insertAndGet
methods.
Postgres 9.5+ has native upsert support via the ON CONFLICT DO UPDATE
clause which can be appended to inserts, see: https://www.postgresql.org/docs/9.5/static/sql-insert.html
What do you think of adding support for upsert into pogi?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.