diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-12-02 10:06:21 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-12-02 10:06:21 +0100 |
commit | fd841e416881cc0392e61ec312c1870f3a0004bd (patch) | |
tree | 8357ba56e79d614ba57f722e7878b853591dc339 /docs/tutorial/tut_mongo_sync_insert.h |
Initial import of libmongo-client version 0.1.8-2
Diffstat (limited to 'docs/tutorial/tut_mongo_sync_insert.h')
-rw-r--r-- | docs/tutorial/tut_mongo_sync_insert.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/docs/tutorial/tut_mongo_sync_insert.h b/docs/tutorial/tut_mongo_sync_insert.h new file mode 100644 index 0000000..aaf0754 --- /dev/null +++ b/docs/tutorial/tut_mongo_sync_insert.h @@ -0,0 +1,46 @@ +/** @page tut_mongo_sync_insert Inserting documents into MongoDB + * + * Now that we know how to connect, it is time to take another step + * forward, and put something into our database. We already learned + * how to build BSON objects in @ref tut_bson_build, so lets put that + * knowledge together, and insert a document! + * + * @dontinclude tut_mongo_sync.c + * @skip tut_sync_connect_replica + * @skip } + * @skip void + * @until { + * + * First, we define a couple of variables, a connection, and three documents: + * + * @until bson + * + * Then we do our routine connect: + * @until } + * + * And then build a BSON object, as we've learned earlier: + * @until bson_finish + * + * Now we have a connection, and we have a document, it's time to get + * dirty, and insert: + * + * @until } + * + * One might wonder what that @c NULL is at the end of + * mongo_sync_cmd_insert()'s argument list: it's the @a sentinel. The + * value that marks the end of the documents we want to insert. It is + * needed, because the insert command can take any number of + * documents, and it will try to insert them in bulk. + * + * Lets try that, and build two more documents: + * @until bson_finish (doc3) + * + * Then we insert the two new documents into the same collection, at + * the same time: + * @until } + * + * And we're done! It's that straightforward. All we have left is + * cleaning up! + * + * @until } + */ |