summaryrefslogtreecommitdiff
path: root/s/strategy.cpp
diff options
context:
space:
mode:
authorAntonin Kral <a.kral@bobek.cz>2011-09-14 17:08:06 +0200
committerAntonin Kral <a.kral@bobek.cz>2011-09-14 17:08:06 +0200
commit5d342a758c6095b4d30aba0750b54f13b8916f51 (patch)
tree762e9aa84781f5e3b96db2c02d356c29cf0217c0 /s/strategy.cpp
parentcbe2d992e9cd1ea66af9fa91df006106775d3073 (diff)
downloadmongodb-5d342a758c6095b4d30aba0750b54f13b8916f51.tar.gz
Imported Upstream version 2.0.0
Diffstat (limited to 's/strategy.cpp')
-rw-r--r--s/strategy.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/s/strategy.cpp b/s/strategy.cpp
index 7c1fb0b..4230b7f 100644
--- a/s/strategy.cpp
+++ b/s/strategy.cpp
@@ -38,7 +38,7 @@ namespace mongo {
conn.donotCheckVersion();
else if ( conn.setVersion() ) {
conn.done();
- throw StaleConfigException( r.getns() , "doWRite" , true );
+ throw StaleConfigException( r.getns() , "doWrite" , true );
}
conn->say( r.m() );
conn.done();
@@ -46,6 +46,8 @@ namespace mongo {
void Strategy::doQuery( Request& r , const Shard& shard ) {
+ r.checkAuth();
+
ShardConnection dbcon( shard , r.getns() );
DBClientBase &c = dbcon.conn();
@@ -67,13 +69,31 @@ namespace mongo {
dbcon.done();
}
- void Strategy::insert( const Shard& shard , const char * ns , const BSONObj& obj ) {
+ void Strategy::insert( const Shard& shard , const char * ns , const BSONObj& obj , int flags, bool safe ) {
ShardConnection dbcon( shard , ns );
if ( dbcon.setVersion() ) {
dbcon.done();
throw StaleConfigException( ns , "for insert" );
}
- dbcon->insert( ns , obj );
+ dbcon->insert( ns , obj , flags);
+ if (safe)
+ dbcon->getLastError();
dbcon.done();
}
+
+ void Strategy::update( const Shard& shard , const char * ns , const BSONObj& query , const BSONObj& toupdate , int flags, bool safe ) {
+ bool upsert = flags & UpdateOption_Upsert;
+ bool multi = flags & UpdateOption_Multi;
+
+ ShardConnection dbcon( shard , ns );
+ if ( dbcon.setVersion() ) {
+ dbcon.done();
+ throw StaleConfigException( ns , "for insert" );
+ }
+ dbcon->update( ns , query , toupdate, upsert, multi);
+ if (safe)
+ dbcon->getLastError();
+ dbcon.done();
+ }
+
}