GithubHelp home page GithubHelp logo

Comments (17)

mdvorak avatar mdvorak commented on May 18, 2024

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.

vitaly-t avatar vitaly-t commented on May 18, 2024

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.

mdvorak avatar mdvorak commented on May 18, 2024

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.

vitaly-t avatar vitaly-t commented on May 18, 2024

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.

vitaly-t avatar vitaly-t commented on May 18, 2024

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.

vitaly-t avatar vitaly-t commented on May 18, 2024

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.

mdvorak avatar mdvorak commented on May 18, 2024

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.

vitaly-t avatar vitaly-t commented on May 18, 2024

Very good. I'm adding support for queryRaw right now ;) It makes perfect sense. Cheers!

from pg-promise.

vitaly-t avatar vitaly-t commented on May 18, 2024

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.

mdvorak avatar mdvorak commented on May 18, 2024

Thats great news, thanks!

from pg-promise.

vitaly-t avatar vitaly-t commented on May 18, 2024

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.

vitaly-t avatar vitaly-t commented on May 18, 2024

Raw Result example has been added to the Learn by Example tutorial ;)

from pg-promise.

vitaly-t avatar vitaly-t commented on May 18, 2024

@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.

vitaly-t avatar vitaly-t commented on May 18, 2024

@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.

miraage avatar miraage commented on May 18, 2024

https://github.com/vitaly-t/pg-promise/wiki/Learn-by-Example#affected-rows
broken. could you please update wiki?

from pg-promise.

vitaly-t avatar vitaly-t commented on May 18, 2024

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.

vitaly-t avatar vitaly-t commented on May 18, 2024

@miraage The link has been updated: Raw Result

Cheers!

from pg-promise.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.