senecajs / seneca-postgres-store Goto Github PK
View Code? Open in Web Editor NEWPostgreSQL plugin for Seneca
License: MIT License
PostgreSQL plugin for Seneca
License: MIT License
Because the error function has the call
seneca.fail({code: 'entity/error', store: name}, cb)
it will never retry connection as the following code is never executed.
Hi @marianr,
can you please add me to the repo contributors so that I can land the branches ?
Thanks a lot !
On safe mode, an object passed with a key and an undefined value is considered as an incomplete query.
This way, when a query is done with an undefined value it will not return the first value found based upon others criterias, but an error or empty object ?
This is to ensure security so that the created query object contains all the required params and doesn't run with incomplete criterias.
Document limit$ and skip$ at stores
Hi,
are there any migration capabilities for seneca-postgres? I have worked with sequelize before and they offer good tools for working with postgres.
A shrinkwrap should be created and added for requiresafe
checked by code climate.
(More globally we should determine if it's really something we want for all @senecajs/core,
and be a collective choice :)
cc @senecajs/contributors )
cf https://codeclimate.com/github/senecajs/seneca-postgres-store/builds/1
CoderDojo/community-platform#847
When reading data that is escaped the output should be unescaped. Should also make sure that things don't get double-escaped.
Does this adapter support the new Postgre JSON data type and searching with it? It allows Postgre to be used effectively as a document store.
I am trying to sort by "when" column - that is created by seneca-user.
The resulting query is something like this:
# SELECT * FROM sys_login ORDER BY when DESC;
ERROR: syntax error at or near "when"
LINE 1: SELECT * FROM sys_login ORDER BY when DESC;
the following query is running correctly:
# SELECT * FROM sys_login ORDER BY "when" DESC;
"when" column breaks the store, needs to check if an escape is missing
senecajs/seneca-user#51
Using native$
is broken under [email protected]. release
is no longer being passed to the callback.
Before, handle_result
would be called apply
with arguments
: https://github.com/senecajs/seneca/blob/v3.3.0/seneca.js#L1029
By nature, the release
function would come through.
Now, arguments
is no longer passed and so this parameter gets lost:
https://github.com/senecajs/seneca/blob/v3.4.2/seneca.js#L904
native
is pretty much broken without the ability to close the connection.
I'm not sure if there's a way within seneca to pass additional arguments to callback functions anymore. To mitigate this, it might be good to manage a pool internally within the store and emit a new client when native$ is invoked. Returning the client will allow end-users to call end
on it.
This is, AFAIK, available on later versions of pg
. This module, as it stands will need to make a few changes to work with pg@7 but I think it's probably a good call to perform the upgrade.
We've already forked this module internally to support schemas.... I'm going to do some work to upgrade to pg@latest
and fix up this native issue. I'll see if I can't put together a PR for this repo.
All tests pass but there is a possible leak with 'Reflect'. https://travis-ci.org/senecajs/seneca-postgres-store/builds/129070772 #65
Update the seneca-store-test dependency to 1.1.0. Over 50 tests added to the new store test version.
29 out of 95 tests are failing, these must be investigated and fixed after update
Audit packages and eliminate vulnerabilities, if any.
Please add to the readme that by default the entity.id field is set to UUID()
However, if your PostgreSQL instance isn't setup you will not be able to insert new records.
CREATE EXTENSION 'uuid-ossp'; needs to be enabled on the database.
Also to override the entity.id field please note that you have to call entity.id$
What this intentional?
This is what it currently does:
https://github.com/senecajs/seneca-postgres-store/blob/master/lib/query-builder.js#L396-L398
This is a pretty big problem for people running this code across a microservice fleet right now especially if they are unaware of this. I believe the intention is to keep the 20 item limit since that is mentioned in comments.
The code used to read (we have it on an old private repo):
- if (q.limit$) {
- mq.params.push('LIMIT ' + q.limit$)
- }
- else {
- if (nolimit === false) {
- mq.params.push('LIMIT 20')
- }
- }
MySQL store has an autoincrement feature implemented. Would be nice to have it also on Postgres.
https://github.com/senecajs/seneca-mysql-store/blob/master/mysql-store.js#L203
Implement a test or sample application that demonstrates how the users using postgres store 1.x should provide backward compatibility using the new postgres 2.x
node-pg supports pooling whereas we create a new connection every request in the current scenario.
Was there any reason to not use them in the first place?
Removed the internal conversion that the plugin was making from CamelCase column names to Snake case. Backward compatibility is ensured by allowing the user to pass into options two functions named toColumnName() and fromColumnName() that make this conversion. These should implement the CamelCase to Snake case conversion. More details are provided in the seneca-standard-query Column name transformation, backward compatibility section.
All query generation code related to basic seneca functionality was moved to seneca-standard-query and the extended query functionality moved to seneca-store-query. This doesn't change functionality but enables functionality reuse into other stores.
Please view the change log for a list of changes through the years.
Please visit http://senecajs.org/ for more information on support and how to contribute
When using fields$ if the id is specified explicitly then the id is added twice in the generated query.
foo.list$({ids: ['foo1', 'foo2'], fields$: ['id']}
generates SELECT id, id FROM foo WHERE
This appears on both cases: when id or array of ids is used.
Some tests fail with seneca 2.0. Seem to be related to the ready() functionality in seneca 2.0.
Investigate it and fill a bug report on seneca.
A default 'id' field of type UUID seems to be automatically generated even if I do not specify one. There seems to be some sorcery involved using the id$ field that is not clearly documented - what is needed while doing a save$, is for the id field not to be even part of the save process, but that the callback have the (saved) id set on the entity. Is it possible to do this, and how ?
If connection object contains schema then this should be used when building queries.
On gitter one user reported an undefined fromColumnName issue. This is the text:
when running unit test with seneca-postresql-store, I got these error
1) user profile test happy:
Uncaught TypeError: Cannot read property 'fromColumnName' of undefined
at Object.internals.transformDBRowToJSObject (node_modules/seneca-postgresql-store/lib/postgresql-store.js:299:26)
at node_modules/seneca-postgresql-store/lib/postgresql-store.js:184:35
at .<anonymous> (node_modules/seneca-postgresql-store/lib/postgresql-store.js:123:18)
I check source and need to work around to fix this issue
internals.transformDBRowToJSObject = function (row) {
var obj = {}
// here where I work around
if (StandardQuery == null) {
StandardQuery = seneca.export('standard-query/utils')
}
for (var attr in row) {
if (row.hasOwnProperty(attr)) {
obj[StandardQuery.fromColumnName(attr)] = row[attr]
}
}
return obj
}
var fields = ent.fields$()
var entp = relationalstore.makeentp(ent)
fields should be created after makeentp is called. It should also be created from entp fields because makeentp can add 'seneca' field and this should be considered in the update stm
seneca-postgres-store is published on npm both as seneca-postgres-store and as seneca-postgresql-store. One of them should be deprecated
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.