From e12ac2313137b8f3ab8e4c56a507d071af6fe074 Mon Sep 17 00:00:00 2001 From: Thomas Risberg Date: Mon, 14 Feb 2011 16:03:05 -0500 Subject: [PATCH] DATADOC-30 updated documenation --- src/docbkx/reference/mongodb.xml | 448 ++++++++++++++++++------------- 1 file changed, 268 insertions(+), 180 deletions(-) diff --git a/src/docbkx/reference/mongodb.xml b/src/docbkx/reference/mongodb.xml index f6c93f287..462953473 100644 --- a/src/docbkx/reference/mongodb.xml +++ b/src/docbkx/reference/mongodb.xml @@ -355,39 +355,51 @@ public class AppConfig { - MongoTemplate(Mongo mongo, String databaseName) - takes the - default database name to operate against + MongoTemplate(Mongo mongo, String + databaseName) - takes the default database name to + operate against - MongoTemplate(Mongo mongo, String databaseName, String - defaultCollectionName) - adds the default collection name to - operate against. + MongoTemplate(Mongo mongo, String + databaseName, String defaultCollectionName) - adds the + default collection name to operate against. - MongoTemplate(Mongo mongo, String databaseName, String - defaultCollectionName, MongoConverter mongoConverter) - override - with a provided MongoConverter. Default is - SimpleMongoConverter + MongoTemplate(Mongo mongo, String + databaseName, String defaultCollectionName, MongoConverter + mongoConverter) - override with a provided + MongoConverter. Default is SimpleMongoConverter - MongoTemplate(Mongo mongo, String databaseName, String - defaultCollectionName, MongoConverter mongoConverter, WriteConcern - writeConcern, WriteResultChecking writeResultChecking) - Specify a - default WriteConcern and also WriteResultChecking policy + MongoTemplate(Mongo mongo, String + databaseName, String defaultCollectionName, MongoConverter + mongoConverter, WriteConcern writeConcern, WriteResultChecking + writeResultChecking) - Specify a default WriteConcern + and also WriteResultChecking policy - MongoTemplate(Mongo mongo, String databaseName, String - defaultCollectionName, WriteConcern writeConcern, - WriteResultChecking writeResultChecking) + MongoTemplate(Mongo mongo, String + databaseName, String defaultCollectionName, WriteConcern + writeConcern, WriteResultChecking writeResultChecking)- + Specify a default WriteConcern and also WriteResultChecking + policy - MongoTemplate(Mongo mongo, String databaseName, WriteConcern - writeConcern, WriteResultChecking writeResultChecking) + MongoTemplate(Mongo mongo, String + databaseName, WriteConcern writeConcern, WriteResultChecking + writeResultChecking)- Specify a default WriteConcern and + also WriteResultChecking policy @@ -421,53 +433,60 @@ public class AppConfig { - Set<String> getCollectionNames() A set of collection - names. + Set<String> getCollectionNames() A + set of collection names. - boolean collectionExists(java.lang.String collectionName) - Check to see if a collection with a given name exists. + boolean collectionExists(String + collectionName) Check to see if a collection with a + given name exists. - com.mongodb.DBCollection createCollection(String - collectionName) Create an uncapped collection with the provided + DBCollection createCollection(String + collectionName) Create an uncapped collection with the + provided name. + + + + DBCollection createCollection(String + collectionName, CollectionOptions collectionOptions) + Create a collect with the provided name and options. + + + + void dropCollection(String + collectionName) Drop the collection with the given name. - com.mongodb.DBCollection createCollection(String - collectionName, CollectionOptions collectionOptions) Create a - collect with the provided name and options. + DBCollection getCollection(String + collectionName) Get a collection by name, creating it + if it doesn't exist. - void dropCollection(java.lang.String collectionName) Drop - the collection with the given name. + DBCollection getDefaultCollection() + The default collection used by this template. - com.mongodb.DBCollection getCollection(java.lang.String - collectionName) Get a collection by name, creating it if it - doesn't exist. - - - - com.mongodb.DBCollection getDefaultCollection() The - default collection used by this template. - - - - String getDefaultCollectionName() The default collection - name used by this template. - - - - com.mongodb.DBCollection getDefaultCollection() The - default collection used by this template. + String getDefaultCollectionName() + The default collection name used by this template. + +
@@ -475,41 +494,50 @@ public class AppConfig { - com.mongodb.CommandResult - executeCommand(com.mongodb.DBObject command) Execute a MongoDB - command. + CommandResult executeCommand(DBObject + command) Execute a MongoDB command. - com.mongodb.CommandResult executeCommand(String - jsonCommand) Execute the a MongoDB command expressed as a JSON - string. + CommandResult executeCommand(String + jsonCommand) Execute the a MongoDB command expressed + as a JSON string. - <T> T execute(CollectionCallback<T> action) - Executes the given CollectionCallback on the default - collection. + <T> T execute(CollectionCallback<T> + action) Executes the given CollectionCallback on the + default collection. - <T> T execute(CollectionCallback<T> action, - String collectionName) Executes the given CollectionCallback on - the collection of the given name. + <T> T execute(String collectionName, + CollectionCallback<T> action) Executes the given + CollectionCallback on the collection of the given name. - <T> T execute(DbCallback<T> action) Executes a - DbCallback translating any exceptions as necessary. + <T> T execute(DbCallback<T> + action) Executes a DbCallback translating any + exceptions as necessary. - <T> T executeInSession(DbCallback<T> action) - Executes the given DbCallback within the same connection to the - database so as to ensure consistency in a write heavy - environment where you may read the data that you wrote. + <T> T executeInSession(DbCallback<T> + action) Executes the given DbCallback within the same + connection to the database so as to ensure consistency in a + write heavy environment where you may read the data that you + wrote. + +
@@ -517,17 +545,22 @@ public class AppConfig { - void ensureIndex(IndexSpecification indexSpecification) - Ensure that an index for the provided IndexSpecification exists - for the default collection. + void ensureIndex(IndexDefinition + indexDefintion) Ensure that an index for the provided + IndexDefinition exists for the default collection. - void ensureIndex(String collectionName, IndexSpecification - indexSpecification) Ensure that an index for the provided - IndexSpecification exists. + void ensureIndex(String + collectionName, IndexDefinition indexSpecification) + Ensure that an index for the provided IndexDefinition + exists. + +
@@ -535,55 +568,69 @@ public class AppConfig { - void insert(java.lang.Object objectToSave) Insert the - object into the default collection. + void insert(Object + objectToSave) Insert the object into the default + collection. - void insert(java.lang.String collectionName, - java.lang.Object objectToSave) Insert the object into the + void insert(String collectionName, + Object objectToSave) Insert the object into the specified collection. - void insertList(java.util.List<? extends - java.lang.Object> listToSave) Insert a list of objects into + void insertList(List<? extends + Object> listToSave) Insert a list of objects into the default collection in a single batch write to the database. - void insertList(java.lang.String collectionName, - java.util.List<? extends java.lang.Object> listToSave) - Insert a list of objects into the specified collection in a - single batch write to the database. + void insertList(String + collectionName, List<? extends Object> + listToSave) Insert a list of objects into the + specified collection in a single batch write to the + database. - <T> void insert(T objectToSave, MongoWriter<T> - writer) Insert the object into the default collection. + <T> void insert(T objectToSave, + MongoWriter<T> writer) Insert the object into + the default collection. - <T> void insert(String collectionName, T - objectToSave, MongoWriter<T> writer) Insert the object - into the specified collection. + <T> void insert(String collectionName, T + objectToSave, MongoWriter<T> writer) Insert the + object into the specified collection. - <T> void insertList(List<? extends T> - listToSave, MongoWriter<T> writer) Insert a list of - objects into the default collection using the provided + <T> void insertList(List<? extends + T> listToSave, MongoWriter<T> writer) Insert + a list of objects into the default collection using the provided MongoWriter instance - <T> void insertList(String collectionName, List<? - extends T> listToSave, MongoWriter<T> writer) Insert a - list of objects into the specified collection using the provided - MongoWriter instance + <T> void insertList(String + collectionName, List<? extends T> listToSave, + MongoWriter<T> writer) Insert a list of objects + into the specified collection using the provided MongoWriter + instance + +
@@ -591,87 +638,106 @@ public class AppConfig { - <T> List<T> getCollection(Class<T> - targetClass) Query for a list of objects of type T from the - default collection. + <T> List<T> getCollection(Class<T> + targetClass) Query for a list of objects of type T + from the default collection. - <T> List<T> getCollection(String - collectionName, Class<T> targetClass) Query for a list of - objects of type T from the specified collection. + <T> List<T> getCollection(String + collectionName, Class<T> targetClass) Query for + a list of objects of type T from the specified + collection. - <T> List<T> getCollection(String + <T> List<T> getCollection(String collectionName, Class<T> targetClass, MongoReader<T> - reader) Query for a list of objects of type T from the specified - collection, mapping the DBObject using the provided + reader) Query for a list of objects of type T from the + specified collection, mapping the DBObject using the provided MongoReader. - <T> T findOne(Query query, Class<T> - targetClass) Map the results of an ad-hoc query on the default - MongoDB collection to a single instance of an object of the - specified type. - - - - <T> T findOne(Query query, Class<T> - targetClass, MongoReader<T> reader) Map the results of an + <T> T findOne(Query query, + Class<T> targetClass) Map the results of an ad-hoc query on the default MongoDB collection to a single instance of an object of the specified type. - <T> T findOne(java.lang.String collectionName, Query - query, Class<T> targetClass) Map the results of an ad-hoc - query on the specified collection to a single instance of an - object of the specified type. + <T> T findOne(Query query, + Class<T> targetClass, MongoReader<T> + reader) Map the results of an ad-hoc query on the + default MongoDB collection to a single instance of an object of + the specified type. - <T> T findOne(java.lang.String collectionName, Query - query, Class<T> targetClass, MongoReader<T> reader) - Map the results of an ad-hoc query on the specified collection - to a single instance of an object of the specified type. - - - - <T> List<T> find(Query query, Class<T> - targetClass) Map the results of an ad-hoc query on the default - MongoDB collection to a List of the specified type. - - - - <T> List<T> find(Query query, Class<T> - targetClass, MongoReader<T> reader) Map the results of an - ad-hoc query on the default MongoDB collection to a List of the + <T> T findOne(java.lang.String + collectionName, Query query, Class<T> + targetClass) Map the results of an ad-hoc query on the + specified collection to a single instance of an object of the specified type. - <T> List<T> find(String collectionName, Query - query, Class<T> targetClass) Map the results of an ad-hoc - query on the specified collection to a List of the specified + <T> T findOne(java.lang.String + collectionName, Query query, Class<T> targetClass, + MongoReader<T> reader) Map the results of an + ad-hoc query on the specified collection to a single instance of + an object of the specified type. + + + + <T> List<T> find(Query query, Class<T> + targetClass) Map the results of an ad-hoc query on the + default MongoDB collection to a List of the specified type. - <T> List<T> find(String collectionName, Query - query, Class<T> targetClass, CursorPreparer preparer) Map - the results of an ad-hoc query on the specified collection to a - List of the specified type. + <T> List<T> find(Query query, Class<T> + targetClass, MongoReader<T> reader) Map the + results of an ad-hoc query on the default MongoDB collection to + a List of the specified type. - <T> List<T> find(String collectionName, Query - query, Class<T> targetClass, MongoReader<T> reader) - Map the results of an ad-hoc query on the specified collection - to a List of the specified type. + <T> List<T> find(String collectionName, + Query query, Class<T> targetClass) Map the + results of an ad-hoc query on the specified collection to a List + of the specified type. + + + + <T> List<T> find(String collectionName, + Query query, Class<T> targetClass, CursorPreparer + preparer) Map the results of an ad-hoc query on the + specified collection to a List of the specified type. + + + + <T> List<T> find(String collectionName, + Query query, Class<T> targetClass, MongoReader<T> + reader) Map the results of an ad-hoc query on the + specified collection to a List of the specified type. + +
@@ -679,27 +745,36 @@ public class AppConfig { - void save(Object objectToSave) Save the object to the - default collection. + void save(Object + objectToSave) Save the object to the default + collection. - void save(String collectionName, Object objectToSave) Save - the object to the specified collection. + void save(String collectionName, + Object objectToSave) Save the object to the specified + collection. - <T> void save(T objectToSave, MongoWriter<T> - writer) Save the object into the default collection using the - provided writer. + <T> void save(T objectToSave, + MongoWriter<T> writer) Save the object into the + default collection using the provided writer. - <T> void save(String collectionName, T objectToSave, - MongoWriter<T> writer) Save the object into the specified - collection using the provided writer. + <T> void save(String collectionName, T + objectToSave, MongoWriter<T> writer) Save the + object into the specified collection using the provided + writer. + +
@@ -707,17 +782,22 @@ public class AppConfig { - void remove(Query query) Remove all documents from the - default collection that match the provided query document - criteria. + void remove(Query query) + Remove all documents from the default collection that match the + provided query document criteria. - void remove(String collectionName, Query query) Remove all - documents from the specified collection that match the provided - query document criteria. + void remove(String collectionName, + Query query) Remove all documents from the specified + collection that match the provided query document + criteria. + +
@@ -725,33 +805,41 @@ public class AppConfig { - com.mongodb.WriteResult updateFirst(Query query, Update - update) Updates the first object that is found in the default - collection that matches the query document with the provided - updated document. - - - - com.mongodb.WriteResult updateFirst(String collectionName, - Query query, Update update) Updates the first object that is - found in the specified collection that matches the query - document criteria with the provided updated document. - - - - com.mongodb.WriteResult updateMulti(Query query, Update - update) Updates all objects that are found in the default - collection that matches the query document criteria with the + WriteResult updateFirst(Query query, Update + update) Updates the first object that is found in the + default collection that matches the query document with the provided updated document. - com.mongodb.WriteResult updateMulti(String collectionName, - Query query, Update update) Updates all objects that are found - in the specified collection that matches the query document - criteria with the provided updated document. + WriteResult updateFirst(String + collectionName, Query query, Update update) Updates + the first object that is found in the specified collection that + matches the query document criteria with the provided updated + document. + + + + WriteResult updateMulti(Query query, Update + update) Updates all objects that are found in the + default collection that matches the query document criteria with + the provided updated document. + + + + WriteResult updateMulti(String + collectionName, Query query, Update update) Updates + all objects that are found in the specified collection that + matches the query document criteria with the provided updated + document. + +
@@ -760,7 +848,7 @@ public class AppConfig { It's time to look at some code examples showing how to use the MongoTemplate. First we look at creating our - first colection. + first collection. Working with collections using the MongoTemplate