Comments (17)
MyBatis solves this by having methods like selectOne
, selectList
, selectMap
for data retrieval
and delete
, update
, insert
for modifications. It is explicit, but i thing actually method update
with rowCount
as result would suffice.
My original solution provides you access to full result object, which allows future users to get any possible future properties available there :) Also might allow easier transition from pure pg/other libraries to this one. Therefore, I would still include it.
from pg-promise.
I'd like to see that no other fix is possible in the meantime, before opting for a breaking change. I'll try to come up with some ideas....
from pg-promise.
My PR wasn't breaking, it just added new queryResult. But having .update(...).then(function(rowCount) {});
would serve as well. I can't think of case where you would need both data and rowCount.
If you don't want to have generic passthru method, this is my suggestion.
from pg-promise.
Method query
already has all the information, it just needs to return the extra result. This can be achieved either through an extra option added to the method or another method name. I would't call it anything specific to update/insert/delete, because it should remain generic.
Something like queryCount
?
from pg-promise.
You know, I think I have a better idea...
How about, we add method called something like raw
and have it resolve with the entire result
object as returned from pg
? This would be your passthrough
method.
The more I think about it, the more I like it, except perhaps for the method name :)
Thinking of a better name, please throw in some of your own ;)
direct
getAll
get
rawData
rawQuery
result
getResult
Right now I think the one that best fits the architecture logic is rawQuery
.
from pg-promise.
I can't think of case where you would need both data and rowCount.
Well, if you execute something like this:
UPDATE users SET login = 'myName' RETURNING id
I just tested it, and I got both. Although now the row.length is the same as rowCount, so probably not so important... I'm just not quite sure...
from pg-promise.
Well, that still produces rows array, therefore you have its length property.
But I was also originally thinking about raw
as queryResult
, so rawQuery
or queryRaw
sounds fine to me. queryRaw fits me better, since you are executing query and consuming raw result. While rawQuery would make me think i'm bypassing pg-promise query formatting (pgFormatting=true).
from pg-promise.
Very good. I'm adding support for queryRaw
right now ;) It makes perfect sense. Cheers!
from pg-promise.
I have implemented, tested, and checked in the changes. You can get them from the current index.js in the master branch.
New method queryRaw(query, values)
will resolve with the PG's result
.
There will be some documentation, and perhaps extra tests added before I release it as 1.0.3 (it's not a breaking change).
from pg-promise.
Thats great news, thanks!
from pg-promise.
Version 1.0.3 has been released. There were some changes in the source after all, to fix an issue found after adding a few good tests, which is always nice.
I will be adding an example to the Learn by Example tutorial shortly, but in the meantime the issue is closed.
Thank you for your help! 👍
from pg-promise.
Raw Result example has been added to the Learn by Example tutorial ;)
from pg-promise.
@mdvorak, Unrelated to this, but if you liked this library, I really appreciate if you can give me a feedback on this small addition: pg-monitor
from pg-promise.
@mdvorak reflecting on some of the passed changes, added method result
in Release 1.7.4 as another alias to queryRaw
, because this is what it should have been called.
from pg-promise.
https://github.com/vitaly-t/pg-promise/wiki/Learn-by-Example#affected-rows
broken. could you please update wiki?
from pg-promise.
Where is this link declared?
On 10 December 2015 at 16:13, Mikhail Osher [email protected]
wrote:
https://github.com/vitaly-t/pg-promise/wiki/Learn-by-Example#affected-rows
broken. could you please update wiki?—
Reply to this email directly or view it on GitHub
#17 (comment).
from pg-promise.
@miraage The link has been updated: Raw Result
Cheers!
from pg-promise.
Related Issues (20)
- Query methods are failing due to legacy Array checking methods not working with cross-realm objects HOT 2
- 10.15.1 crash on NodeJS 12 HOT 1
- IClient.release() has no return type annotation HOT 4
- Query re: WARNING: Creating a duplicate database object for the same connection HOT 3
- Request to update the RobustListener example to use async/await HOT 1
- Add https:// to link in About section HOT 2
- Is it possible to enum and timestamp using pgp.helpers.update? HOT 1
- Error not being thrown when statement cancelled due to timeout HOT 5
- batch is deprecated?
- ColumnSet does not recognize a table with schema HOT 6
- Question: Is it possible to use pg.helpers.ColumnSet to skip updating value based on column's new value
- CI issue HOT 3
- How safe is helpers concat against SQL injections HOT 1
- pg return error HOT 6
- CSV filter not treating Buffer (bytea) correctly HOT 6
- Using Promise.all inside tx() causes inconsistent data state HOT 7
- How can I explain my transaction ? HOT 1
- How can I delete a set of values ? HOT 1
- BUG - JSON and JSONB cast on update helper HOT 3
- json formatting issue on update HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pg-promise.