[odb-users] update object without caching the query result

Tim Tao Tim.Tao at akunacapital.com
Thu Sep 24 11:35:38 EDT 2015


Hi Boris,

Thanks for your reply.

The following is the code fragment:

using query = odb::query<A>;
using result = odb::result<A>;

result r(db->query<A>(some conditions here));

for(result::iterator::iterator i (r.begin()); i != r.end(); ++i){
            shared_ptr<A> ptr = i.load();
            ptr->field = new_value;
            db->update(ptr);
}

So in this way I have to cache each result which seems unnecessary to me since I don't need them in the future once I finished updating

I wonder if there is any way I can update the results without loading them to cache ?

By the way, I am using postgres

Thanks,

Tim
________________________________________
From: Boris Kolpackov <boris at codesynthesis.com>
Sent: Thursday, September 24, 2015 10:26 AM
To: Tim Tao
Cc: odb-users at codesynthesis.com
Subject: Re: [odb-users] update object without caching the query result

Hi Tim,

Tim Tao <Tim.Tao at akunacapital.com> writes:

> Is there any way we can update an object without caching the
> query result ?
>
> I query the database and load() each result, it seems like this
> will cache the result in the application memory which is unnecessary.

There is a "query result", i.e., what's returned by the call to
query(), which, for some databases, may involve caching of the raw
data. When you call load() (presumably on result::iterator), you
load the "object". When you say "will cache the result", which
one do you refer to?

Also, it is always a good idea to show the code fragment.

Boris
________________________________
 [http://www.akunacapital.com/images/akuna.png]
Tim Tao | Junior Developer

    | www.akunacapital.com <http://www.akunacapital.com>
p:  | m:  | f:  | tim.tao at akunacapital.com

Please consider the environment, before printing this email.

This electronic message contains information from Akuna Capital LLC that may be confidential, legally privileged or otherwise protected from disclosure. This information is intended for the use of the addressee only and is not offered as investment advice to be relied upon for personal or professional use. Additionally, all electronic messages are recorded and stored in compliance pursuant to applicable SEC rules. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, printing or any other use of, or any action in reliance on, the contents of this electronic message is strictly prohibited. If you have received this communication in error, please notify us by telephone at (312)994-4640 and destroy the original message.



More information about the odb-users mailing list