diff options
author | Eliot Horowitz <eliot@10gen.com> | 2010-04-20 17:07:07 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2010-04-20 17:07:07 -0400 |
commit | 9314ac2ca6c8e44ca651e77e21f6d98b29a2247d (patch) | |
tree | e90d0c31615a061999db4df2d4b05a64310a260b /client | |
parent | 517d8f02777c0bb547f78ba96573e99e7372c735 (diff) | |
download | mongo-9314ac2ca6c8e44ca651e77e21f6d98b29a2247d.tar.gz |
some helpers
Diffstat (limited to 'client')
-rw-r--r-- | client/model.cpp | 12 | ||||
-rw-r--r-- | client/model.h | 4 |
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. |