MongoSchema

Mixin for functions for interacting with Mongo collections.

mixin template MongoSchema () {}

Members

Functions

merge
void merge()

Inserts or merges into an existing value.

remove
bool remove()

Removes this object from the collection. Returns false when _id of this is not set.

save
void save()

Inserts or updates an existing value.

Properties

bsonID
BsonObjectID bsonID [@property getter]
const(BsonObjectID) bsonID [@property getter]
collection
MongoCollection collection [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Static functions

aggregate
SchemaPipeline aggregate()

Start of an aggregation call. Returns a pipeline with typesafe functions for modifying the pipeline and running it at the end.

count
auto count(T query)

Returns the count of documents in this collection matching this query.

count
auto count(Query!(typeof(this)) query)

Returns the count of documents in this collection matching this query.

countAll
auto countAll()

Returns the count of documents in this collection.

dropTable
void dropTable()

Drops the entire collection and all indices in the database.

find
typeof(this)[] find(Query!(typeof(this)) query, QueryFlags flags, int num_skip, int num_docs_per_chunk)
typeof(this)[] find(T query, QueryFlags flags, int num_skip, int num_docs_per_chunk)

Finds one or more elements using a query.

findAll
DocumentRange!(typeof(this)) findAll()

Queries all elements from the collection as range.

findById
typeof(this) findById(BsonObjectID id)

Finds one element with the object id id.

findById
typeof(this) findById(string id)

Finds one element with the hex id id.

findOne
typeof(this) findOne(Query!(typeof(this)) query)
typeof(this) findOne(T query)

Finds one element using a query.

findOneOrThrow
Bson findOneOrThrow(Query!(typeof(this)) query)
Bson findOneOrThrow(T query)

Tries to find one document in the collection.

findRange
DocumentRange!(typeof(this)) findRange(Query!(typeof(this)) query, QueryFlags flags, int num_skip, int num_docs_per_chunk)
DocumentRange!(typeof(this)) findRange(T query, QueryFlags flags, int num_skip, int num_docs_per_chunk)

Finds one or more elements using a query as range.

insertMany
void insertMany(T documents, InsertFlags options)

Inserts many documents at once. The resulting IDs of the symbols will be generated by the server and not known to the caller.

remove
void remove(Query!(typeof(this)) query, DeleteFlags flags)
void remove(T selector, DeleteFlags flags)

Deletes one or any amount of documents matching the selector based on the flags.

removeAll
void removeAll()

Removes all documents from this collection.

tryFindById
Nullable!(typeof(this)) tryFindById(BsonObjectID id)
Nullable!(typeof(this)) tryFindById(string id)

Tries to find a document by the _id field and returns a Nullable which isNull if it could not be found. Otherwise it will be the document wrapped in the nullable.

tryFindById
typeof(this) tryFindById(BsonObjectID id, typeof(this) defaultValue)
typeof(this) tryFindById(string id, typeof(this) defaultValue)

Tries to find a document by the _id field and returns a default value if it could not be found.

tryFindOne
Nullable!(typeof(this)) tryFindOne(Query!(typeof(this)) query)
Nullable!(typeof(this)) tryFindOne(T query)

Tries to find a document in this collection. It will return a Nullable which isNull if the document could not be found. Otherwise it will be the document wrapped in the nullable.

tryFindOne
typeof(this) tryFindOne(Query!(typeof(this)) query, typeof(this) defaultValue)
typeof(this) tryFindOne(T query, typeof(this) defaultValue)

Tries to find a document in this collection. It will return a default value if the document could not be found.

update
void update(Query!(typeof(this)) query, U update, UpdateFlags options)
void update(T query, U update, UpdateFlags options)

Updates a document.

upsert
void upsert(Query!(typeof(this)) query, U upsert, UpdateFlags options)
void upsert(T query, U update, UpdateFlags options)

Updates a document or inserts it when not existent. Shorthand for update(..., UpdateFlags.upsert)

Static variables

_schema_collection_
MongoCollection _schema_collection_;
Undocumented in source.

Meta