summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-04-20 17:07:07 -0400
committerEliot Horowitz <eliot@10gen.com>2010-04-20 17:07:07 -0400
commit9314ac2ca6c8e44ca651e77e21f6d98b29a2247d (patch)
treee90d0c31615a061999db4df2d4b05a64310a260b /client
parent517d8f02777c0bb547f78ba96573e99e7372c735 (diff)
downloadmongo-9314ac2ca6c8e44ca651e77e21f6d98b29a2247d.tar.gz
some helpers
Diffstat (limited to 'client')
-rw-r--r--client/model.cpp12
-rw-r--r--client/model.h4
2 files changed, 15 insertions, 1 deletions
diff --git a/client/model.cpp b/client/model.cpp
index 397810557aa..f41a4376411 100644
--- a/client/model.cpp
+++ b/client/model.cpp
@@ -94,4 +94,16 @@ namespace mongo {
throw UserException( 9003 , (string)"error on Model::save: " + errmsg );
}
+ BSONObj Model::toObject(){
+ BSONObjBuilder b;
+ serialize( b );
+ return b.obj();
+ }
+
+ void Model::append( const char * name , BSONObjBuilder& b ){
+ BSONObjBuilder bb( b.subobjStart( name ) );
+ serialize( bb );
+ bb.done();
+ }
+
} // namespace mongo
diff --git a/client/model.h b/client/model.h
index f3a63adaeef..907b2eaca4e 100644
--- a/client/model.h
+++ b/client/model.h
@@ -40,7 +40,9 @@ namespace mongo {
virtual const char * getNS() = 0;
virtual void serialize(BSONObjBuilder& to) = 0;
virtual void unserialize(const BSONObj& from) = 0;
-
+ virtual BSONObj toObject();
+ virtual void append( const char * name , BSONObjBuilder& b );
+
virtual string modelServer() = 0;
/** Load a single object.