Module mongorover.MongoCollection

Collection level utilities for Mongo.

Class mongorover.MongoCollection

mongorover.MongoCollection:new (database, collection_name) Creates a new MongoCollection instance.
mongorover.MongoCollection:drop () Drops collection.
mongorover.MongoCollection:count ([query[, skip[, limit]]]) Returns the number of documents in a collection matching the query input parameter.
mongorover.MongoCollection:find ([query[, fields]]) Selects documents in a collection and returns an iterator to the selected documents.
mongorover.MongoCollection:find_one ([query[, fields]]) Returns one document that satisfies the specified query criteria.
mongorover.MongoCollection:update_one (filter, update[, upsert]) Update a single document matching the filter Example usage at update_one.lua.
mongorover.MongoCollection:update_many (filter, update[, upsert]) Update one or more documents that match the filter.
mongorover.MongoCollection:insert_one (document) Insert a single document.
mongorover.MongoCollection:insert_many (documents[, ordered]) Insert a list of documents.
mongorover.MongoCollection:delete_one (selector) Delete a single document.
mongorover.MongoCollection:delete_many (selector) Deletes all documents matching query selector.
mongorover.MongoCollection:aggregate (aggregationPipeline) Perform an aggregation using the aggregation framework on this collection.


Class mongorover.MongoCollection

Collection level utilities for Mongo.
mongorover.MongoCollection:new (database, collection_name)
Creates a new MongoCollection instance. Usually called by MongoDatabase's getCollection(...) method.

Parameters:

  • database MongoDatabase A MongoDatabase instance.
  • collection_name string The name of the collection.

Returns:

    A MongoCollection instance.

See also:

mongorover.MongoCollection:drop ()
Drops collection.
mongorover.MongoCollection:count ([query[, skip[, limit]]])
Returns the number of documents in a collection matching the query input parameter. Example usage at update_many.lua.

Parameters:

  • query table A table containing a query. (optional)
  • skip int The number of documents to skip. (optional)
  • limit int The maximum number of matching documents to return. (optional)

Returns:

    int The number of documents matching the query provided.
mongorover.MongoCollection:find ([query[, fields]])
Selects documents in a collection and returns an iterator to the selected documents. Example usage at find.lua.

Parameters:

  • query table Specifies criteria using query operators. To return all documents, either do not use query parameter or pass in an empty document ({}). (optional)
  • fields table projection Specifies the fields to return using projection operators. Default value returns all fields. (optional)

Returns:

    iterator An iterator with results.
mongorover.MongoCollection:find_one ([query[, fields]])
Returns one document that satisfies the specified query criteria. Example usage at find.lua.

Parameters:

  • query table Specifies criteria using query operators. (optional)
  • fields table Specifies the fields to return using projection operators. Default value returns all fields. (optional)

Returns:

    table First document found with the query provided.
mongorover.MongoCollection:update_one (filter, update[, upsert])
Update a single document matching the filter Example usage at update_one.lua.

Parameters:

  • filter table A query that matches the document to update.
  • update table The modifications to apply.
  • upsert bool If true, perform an insert if no documents match the filter. (optional)

Returns:

    mongorover.resultObjects.UpdateResult
mongorover.MongoCollection:update_many (filter, update[, upsert])
Update one or more documents that match the filter. Example usage at update_many.lua.

Parameters:

  • filter table A query that matches the documents to update.
  • update table The modifications to apply.
  • upsert bool If true, perform an insert if no documents match the filter. (optional)

Returns:

    mongorover.resultObjects.UpdateResult
mongorover.MongoCollection:insert_one (document)
Insert a single document. Example usage at insert_one.lua.

Parameters:

  • document table The document to insert. Must be mutable. If the document does not have an _id field, one will be added automatically.

Returns:

    mongorover.resultObjects.InsertOneResult
mongorover.MongoCollection:insert_many (documents[, ordered])
Insert a list of documents. Example usage at insert_many.lua.

Parameters:

  • documents {table,...} A list of documents to insert.
  • ordered bool If true (the default), documents will be inserted on the server serially, in the order provided. If false, documents will be inserted on the server in arbitrary order (possibly in parallel) and all documents inserts will be attempted (optional)

Returns:

    mongorover.resultObjects.InsertManyResult
mongorover.MongoCollection:delete_one (selector)
Delete a single document. Example usage at delete_one.lua.

Parameters:

  • selector table Specifies criteria using query operators.

Returns:

    mongorover.resultObjects.DeleteResult
mongorover.MongoCollection:delete_many (selector)
Deletes all documents matching query selector. Example usage at delete_many.lua

Parameters:

  • selector table Specifies criteria using query operators.

Returns:

    mongorover.resultObjects.DeleteResult
mongorover.MongoCollection:aggregate (aggregationPipeline)
Perform an aggregation using the aggregation framework on this collection. Example usage at aggregation.lua.

Parameters:

  • aggregationPipeline {table,...} A list of aggregation pipeline stages.

Returns:

    iterator An iterator with results.
generated by LDoc 1.4.3 Last updated 2015-09-16 03:55:02