public static class BatchedWrite.Builder extends Object
BatchedWrite
s.Modifier and Type | Field and Description |
---|---|
protected Durability |
myDurability
The durability for the writes.
|
protected BatchedWriteMode |
myMode
The mode for submitting the writes to the server.
|
protected List<WriteOperation> |
myWrites
The writes to submit to the server.
|
Constructor and Description |
---|
BatchedWrite.Builder()
Creates a new Builder.
|
Modifier and Type | Method and Description |
---|---|
BatchedWrite |
build()
Constructs a new
BatchedWrite object from the state of the
builder. |
BatchedWrite.Builder |
delete(DocumentAssignable query)
Update a document based on a query.
|
BatchedWrite.Builder |
delete(DocumentAssignable query,
boolean singleDelete)
Update a document based on a query.
|
BatchedWrite.Builder |
durability(Durability durability)
Sets the durability for the writes.
|
Durability |
getDurability()
Returns the durability for the write.
|
BatchedWrite.Builder |
insert(DocumentAssignable document)
Adds an insert operation to the batched write.
|
BatchedWrite.Builder |
mode(BatchedWriteMode mode)
Sets the mode for submitting the writes to the server.
|
BatchedWrite.Builder |
reset()
Resets the builder back to its initial state for reuse.
|
BatchedWrite.Builder |
save(DocumentAssignable document)
Saves the
document to MongoDB. |
BatchedWrite.Builder |
setDurability(Durability durability)
Sets the durability for the writes.
|
BatchedWrite.Builder |
setMode(BatchedWriteMode mode)
Sets the mode for submitting the writes to the server.
|
BatchedWrite.Builder |
setWrites(List<WriteOperation> writes)
Sets the writes to submit to the server.
|
BatchedWrite.Builder |
update(DocumentAssignable query,
DocumentAssignable update)
Update a document based on a query.
|
BatchedWrite.Builder |
update(DocumentAssignable query,
DocumentAssignable update,
boolean multiUpdate,
boolean upsert)
Update a document based on a query.
|
BatchedWrite.Builder |
write(WriteOperation write)
Adds a single write to the list of writes to send to the server.
|
BatchedWrite.Builder |
writes(List<WriteOperation> writes)
Sets the writes to submit to the server.
|
protected Durability myDurability
protected BatchedWriteMode myMode
protected final List<WriteOperation> myWrites
public BatchedWrite build()
BatchedWrite
object from the state of the
builder.BatchedWrite
object.public BatchedWrite.Builder delete(DocumentAssignable query)
Defaults to deleting as many documents as match the query.
This method is delegates to
delete(query, false)
query
- The query to find the document to delete.public BatchedWrite.Builder delete(DocumentAssignable query, boolean singleDelete)
Defaults to deleting as many documents as match the query.
query
- The query to find the document to delete.singleDelete
- If true then only a single document will be deleted. If
running in a sharded environment then this field must be
false or the query must contain the shard key.public BatchedWrite.Builder durability(Durability durability)
This method delegates to setDurability(Durability)
.
durability
- The new value for the durability for the writes.public Durability getDurability()
public BatchedWrite.Builder insert(DocumentAssignable document)
document
- The document to insert.public BatchedWrite.Builder mode(BatchedWriteMode mode)
This method delegates to setMode(BatchedWriteMode)
.
mode
- The new value for the mode for submitting the writes to
the server.public BatchedWrite.Builder reset()
public BatchedWrite.Builder save(DocumentAssignable document)
document
to MongoDB.
If the document
does not contain an _id
field then
this method is equivalent to: insert(document)
.
If the document
does contain an _id
field then this
method is equivalent to:
updateAsync(BuilderFactory.start().add(document.get("_id")),
document, false, true)
.
document
- The document to save.public BatchedWrite.Builder setDurability(Durability durability)
durability
- The new value for the durability for the writes.public BatchedWrite.Builder setMode(BatchedWriteMode mode)
mode
- The new value for the mode for submitting the writes to
the server.public BatchedWrite.Builder setWrites(List<WriteOperation> writes)
writes
- The new value for the writes to submit to the server.public BatchedWrite.Builder update(DocumentAssignable query, DocumentAssignable update)
Defaults to updating a single document and not performing an upsert if no document is found.
This method is delegates to
update(query, update, false, false)
query
- The query to find the document to update.update
- The update operations to apply to the document.public BatchedWrite.Builder update(DocumentAssignable query, DocumentAssignable update, boolean multiUpdate, boolean upsert)
Defaults to updating a single document and not performing an upsert if no document is found.
query
- The query to find the document to update.update
- The update operations to apply to the document.multiUpdate
- If true then the update is applied to all of the matching
documents, otherwise only the first document found is
updated.upsert
- If true then if no document is found then a new document
is created and updated, otherwise no operation is
performed.public BatchedWrite.Builder write(WriteOperation write)
write
- The write to add to the list of writes to send to the
server.public BatchedWrite.Builder writes(List<WriteOperation> writes)
This method delegates to setWrites(List)
.
writes
- The new value for the writes to submit to the server.Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.