diff options
author | dwight <dwight@10gen.com> | 2011-04-14 21:22:24 -0400 |
---|---|---|
committer | dwight <dwight@10gen.com> | 2011-04-14 21:22:24 -0400 |
commit | 66eddbed7ae154ea306d8f91d84b4a20eb4e7961 (patch) | |
tree | eec6e1a49312b36b01ba2a0147267d5535eb9173 /client | |
parent | 4a4103a9b8f069f155f91cc3e65073a59e5f65cc (diff) | |
download | mongo-66eddbed7ae154ea306d8f91d84b4a20eb4e7961.tar.gz |
slightly better demo
Diffstat (limited to 'client')
-rw-r--r-- | client/simple_client_demo.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/client/simple_client_demo.cpp b/client/simple_client_demo.cpp index 18003ba70dd..f4278dd4e54 100644 --- a/client/simple_client_demo.cpp +++ b/client/simple_client_demo.cpp @@ -31,6 +31,18 @@ int main() { bo o = BSON( "hello" << "world" ); c.insert("test.foo", o); + + string e = c.getLastError(); + if( !e.empty() ) { + cout << "insert #1 failed: " << e << endl; + } + + // make an index with a unique key constraint + c.ensureIndex("test.foo", BSON("hello"<<1), /*unique*/true); + + c.insert("test.foo", o); // will cause a dup key error on "hello" field + cout << "we expect a dup key error here:" << endl; + cout << " " << c.getLastErrorDetailed().toString() << endl; } catch(DBException& e) { cout << "caught DBException " << e.toString() << endl; |