Opens a MongoDB change stream against the collection to watch for changes. The resulting stream will be notified of all events on this collection that the active user is authorized to see based on the configured MongoDB rules.
Parameters delegate
The delegate that will react to events and errors from the resulting change stream.
queue
Dispatches streaming events to an optional queue, if no queue is provided the main queue is used
Return ValueA ChangeStream which will manage the streaming events.
matchFilter
The $match filter to apply to incoming change events
delegate
The delegate that will react to events and errors from the resulting change stream.
queue
Dispatches streaming events to an optional queue, if no queue is provided the main queue is used
Return ValueA ChangeStream which will manage the streaming events.
Opens a MongoDB change stream against the collection to watch for changes made to specific documents. The documents to watch must be explicitly specified by their _id.
Parameters filterIds
The list of _ids in the collection to watch.
delegate
The delegate that will react to events and errors from the resulting change stream.
queue
Dispatches streaming events to an optional queue, if no queue is provided the main queue is used
Return ValueA ChangeStream which will manage the streaming events.
Encodes the provided value to BSON and inserts it. If the value is missing an identifier, one will be generated for it.
Parameters document
document A Document
value to insert.
completion
The result of attempting to perform the insert. An Id will be returned for the inserted object on sucess
Encodes the provided values to BSON and inserts them. If any values are missing identifiers, they will be generated.
Parameters documents
The Document
values in a bson array to insert.
completion
The result of the insert, returns an array inserted document ids in order.
Finds the documents in this collection which match the provided filter.
Parameters filter
A Document
as bson that should match the query.
options
FindOptions
to use when executing the command.
completion
The resulting bson array of documents or error if one occurs
Returns one document from a collection or view which matches the provided filter. If multiple documents satisfy the query, this method returns the first document according to the query’s sort order or natural order.
Parameters filter
A Document
as bson that should match the query.
options
FindOptions
to use when executing the command.
completion
The resulting bson or error if one occurs
Runs an aggregation framework pipeline against this collection.
Parameters pipeline
A bson array made up of Documents
containing the pipeline of aggregation operations to perform.
completion
The resulting bson array of documents or error if one occurs
Counts the number of documents in this collection matching the provided filter.
DeclarationSwift
@preconcurrency
public func count(filter: Document, limit: Int? = nil, _ completion: @escaping MongoCountBlock)
Parameters filter
A Document
as bson that should match the query.
limit
The max amount of documents to count
completion
Returns the count of the documents that matched the filter.
Deletes a single matching document from the collection.
Parameters filter
A Document
as bson that should match the query.
completion
The result of performing the deletion. Returns the count of deleted objects
Deletes multiple documents
Parameters filter
Document representing the match criteria
completion
The result of performing the deletion. Returns the count of the deletion
Updates a single document matching the provided filter in this collection.
Parameters filter
A bson Document
representing the match criteria.
update
A bson Document
representing the update to be applied to a matching document.
upsert
When true, creates a new document if no document matches the query.
completion
The result of the attempt to update a document.
Updates multiple documents matching the provided filter in this collection.
Parameters filter
A bson Document
representing the match criteria.
update
A bson Document
representing the update to be applied to a matching document.
upsert
When true, creates a new document if no document matches the query.
completion
The result of the attempt to update a document.
Updates a single document in a collection based on a query filter and returns the document in either its pre-update or post-update form. Unlike updateOneDocument
, this action allows you to atomically find, update, and return a document with the same command. This avoids the risk of other update operations changing the document between separate find and update operations.
filter
A bson Document
representing the match criteria.
update
A bson Document
representing the update to be applied to a matching document.
options
RemoteFindOneAndModifyOptions
to use when executing the command.
completion
The result of the attempt to update a document.
Overwrites a single document in a collection based on a query filter and returns the document in either its pre-replacement or post-replacement form. Unlike updateOneDocument
, this action allows you to atomically find, replace, and return a document with the same command. This avoids the risk of other update operations changing the document between separate find and update operations.
filter
A Document
that should match the query.
replacement
A Document
describing the replacement.
options
FindOneAndModifyOptions
to use when executing the command.
completion
The result of the attempt to replace a document.
Removes a single document from a collection based on a query filter and returns a document with the same form as the document immediately before it was deleted. Unlike deleteOneDocument
, this action allows you to atomically find and delete a document with the same command. This avoids the risk of other update operations changing the document between separate find and delete operations.
filter
A Document
that should match the query.
options
FindOneAndModifyOptions
to use when executing the command.
completion
The result of the attempt to delete a document.
Encodes the provided value to BSON and inserts it. If the value is missing an identifier, one will be generated for it.
Return ValueThe object id of the inserted document.
Encodes the provided values to BSON and inserts them. If any values are missing identifiers, they will be generated.
DeclarationSwift
public func insertMany(_ documents: [Document]) async throws -> [AnyBSON]
Parameters documents
The Document
values in a bson array to insert.
The object ids of inserted documents.
Finds the documents in this collection which match the provided filter.
Returns one document from a collection or view which matches the provided filter. If multiple documents satisfy the query, this method returns the first document according to the query’s sort order or natural order.
Finds the documents in this collection which match the provided filter.
DeclarationSwift
public func find(filter: Document, options: FindOptions = .init(),
_isolation: isolated (any Actor)? = #isolation) async throws -> [Document]
Parameters filter
A Document
as bson that should match the query.
options
FindOptions
to use when executing the command.
Array of Document
filtered.
Returns one document from a collection or view which matches the provided filter. If multiple documents satisfy the query, this method returns the first document according to the query’s sort order or natural order.
DeclarationSwift
public func findOneDocument(filter: Document, options: FindOptions = .init(),
_isolation: isolated (any Actor)? = #isolation) async throws -> Document?
Parameters filter
A Document
as bson that should match the query.
options
FindOptions
to use when executing the command.
Runs an aggregation framework pipeline against this collection.
Parameters pipeline
A bson array made up of Documents
containing the pipeline of aggregation operations to perform.
An array of Document
result of the aggregation operation.
Counts the number of documents in this collection matching the provided filter.
DeclarationSwift
public func count(filter: Document, limit: Int? = nil) async throws -> Int
Parameters filter
A Document
as bson that should match the query.
limit
The max amount of documents to count
Return ValueCount of the documents that matched the filter.
Deletes a single matching document from the collection.
DeclarationSwift
public func deleteOneDocument(filter: Document) async throws -> Int
Parameters filter
A Document
as bson that should match the query.
Int
count of deleted documents.
Deletes multiple documents
DeclarationSwift
public func deleteManyDocuments(filter: Document) async throws -> Int
Parameters filter
Document representing the match criteria
Return ValueInt
count of deleted documents.
Updates a single document matching the provided filter in this collection.
Parameters filter
A bson Document
representing the match criteria.
update
A bson Document
representing the update to be applied to a matching document.
upsert
When true, creates a new document if no document matches the query.
Updates multiple documents matching the provided filter in this collection.
Parameters filter
A bson Document
representing the match criteria.
update
A bson Document
representing the update to be applied to a matching document.
upsert
When true, creates a new document if no document matches the query.
Return ValueUpdateResult
result of the updateMany
operation.
Updates a single document in a collection based on a query filter and returns the document in either its pre-update or post-update form. Unlike updateOneDocument
, this action allows you to atomically find, update, and return a document with the same command. This avoids the risk of other update operations changing the document between separate find and update operations.
Overwrites a single document in a collection based on a query filter and returns the document in either its pre-replacement or post-replacement form. Unlike updateOneDocument
, this action allows you to atomically find, replace, and return a document with the same command. This avoids the risk of other update operations changing the document between separate find and update operations.
Removes a single document from a collection based on a query filter and returns a document with the same form as the document immediately before it was deleted. Unlike deleteOneDocument
, this action allows you to atomically find and delete a document with the same command. This avoids the risk of other update operations changing the document between separate find and delete operations.
Updates a single document in a collection based on a query filter and returns the document in either its pre-update or post-update form. Unlike updateOneDocument
, this action allows you to atomically find, update, and return a document with the same command. This avoids the risk of other update operations changing the document between separate find and update operations.
filter
A bson Document
representing the match criteria.
update
A bson Document
representing the update to be applied to a matching document.
options
RemoteFindOneAndModifyOptions
to use when executing the command.
Document
result of the attempt to update a document or nil
if document wasn’t found.
Overwrites a single document in a collection based on a query filter and returns the document in either its pre-replacement or post-replacement form. Unlike updateOneDocument
, this action allows you to atomically find, replace, and return a document with the same command. This avoids the risk of other update operations changing the document between separate find and update operations.
Document
result of the attempt to reaplce a document or nil
if document wasn’t found.
Removes a single document from a collection based on a query filter and returns a document with the same form as the document immediately before it was deleted. Unlike deleteOneDocument
, this action allows you to atomically find and delete a document with the same command. This avoids the risk of other update operations changing the document between separate find and delete operations.
Document
result of the attempt to delete a document or nil
if document wasn’t found.
Creates a publisher that emits a AnyBSON change event each time the MongoDB collection changes.
DeclarationSwift
public func watch() -> Publishers.WatchPublisher
Return Value
A publisher that emits the AnyBSON change event each time the collection changes.
Creates a publisher that emits a AnyBSON change event each time the MongoDB collection changes.
DeclarationSwift
public func watch(filterIds: [ObjectId]) -> Publishers.WatchPublisher
Parameters filterIds
The list of _ids in the collection to watch.
Return ValueA publisher that emits the AnyBSON change event each time the collection changes.
Creates a publisher that emits a AnyBSON change event each time the MongoDB collection changes.
DeclarationSwift
public func watch(matchFilter: Document) -> Publishers.WatchPublisher
Parameters matchFilter
The $match filter to apply to incoming change events.
Return ValueA publisher that emits the AnyBSON change event each time the collection changes.
An async sequence of AnyBSON values containing information about each change to the MongoDB collection
DeclarationSwift
public var changeEvents: AsyncThrowingPublisher<Publishers.WatchPublisher> { get }
An async sequence of AnyBSON values containing information about each change to the MongoDB collection
DeclarationSwift
public func changeEvents(onOpen: @Sendable @escaping () -> Void)
-> AsyncThrowingPublisher<Publishers.WatchPublisher>
Parameters onOpen
A callback which is invoked when the watch stream has initialized on the server. Server-side changes triggered before this callback is invoked may not produce change events.
An async sequence of AnyBSON values containing information about each change to objects with ids contained in filterIds
within the the MongoDB collection.
Swift
public func changeEvents(filterIds: [ObjectId], onOpen: (@Sendable () -> Void)? = nil)
-> AsyncThrowingPublisher<Publishers.WatchPublisher>
Parameters filterIds
Document ids which should produce change events
onOpen
An optional callback which is invoked when the watch stream has initialized on the server. Server-side changes triggered before this callback is invoked may not produce change events.
An async sequence of AnyBSON values containing information about each change to objects within the MongoDB collection matching the given $match filter.
DeclarationSwift
public func changeEvents(matchFilter: Document, onOpen: (@Sendable () -> Void)? = nil)
-> AsyncThrowingPublisher<Publishers.WatchPublisher>
Parameters matchFilter
$match filter to filter the documents which produce change events.
onOpen
An optional callback which is invoked when the watch stream has initialized on the server. Server-side changes triggered before this callback is invoked may not produce change events.
Encodes the provided value to BSON and inserts it. If the value is missing an identifier, one will be generated for it.
Return ValueA publisher that eventually return the object id of the inserted document or Error
.
Encodes the provided values to BSON and inserts them. If any values are missing identifiers, they will be generated.
Parameters documents
The Document
values in a bson array to insert.
A publisher that eventually return the object ids of inserted documents or Error
.
Finds the documents in this collection which match the provided filter.
Parameters filter
A Document
as bson that should match the query.
options
FindOptions
to use when executing the command.
A publisher that eventually return [ObjectId]
of documents or Error
.
Finds the documents in this collection which match the provided filter.
Parameters filter
A Document
as bson that should match the query.
A publisher that eventually return [ObjectId]
of documents or Error
.
Returns one document from a collection or view which matches the provided filter. If multiple documents satisfy the query, this method returns the first document according to the query’s sort order or natural order.
Parameters filter
A Document
as bson that should match the query.
options
FindOptions
to use when executing the command.
A publisher that eventually return Document
or Error
.
Returns one document from a collection or view which matches the provided filter. If multiple documents satisfy the query, this method returns the first document according to the query’s sort order or natural order.
Parameters filter
A Document
as bson that should match the query.
A publisher that eventually return Document
or nil
if document wasn’t found or Error
.
Runs an aggregation framework pipeline against this collection.
Parameters pipeline
A bson array made up of Documents
containing the pipeline of aggregation operations to perform.
A publisher that eventually return Document
or Error
.
Counts the number of documents in this collection matching the provided filter.
DeclarationSwift
func count(filter: Document, limit: Int) -> Future<Int, Error>
Parameters filter
A Document
as bson that should match the query.
limit
The max amount of documents to count
Return ValueA publisher that eventually return Int
count of documents or Error
.
Counts the number of documents in this collection matching the provided filter.
DeclarationSwift
func count(filter: Document) -> Future<Int, Error>
Parameters filter
A Document
as bson that should match the query.
A publisher that eventually return Int
count of documents or Error
.
Deletes a single matching document from the collection.
DeclarationSwift
func deleteOneDocument(filter: Document) -> Future<Int, Error>
Parameters filter
A Document
as bson that should match the query.
A publisher that eventually return Int
count of deleted documents or Error
.
Deletes multiple documents
DeclarationSwift
func deleteManyDocuments(filter: Document) -> Future<Int, Error>
Parameters filter
Document representing the match criteria
Return ValueA publisher that eventually return Int
count of deleted documents or Error
.
Updates a single document matching the provided filter in this collection.
Parameters filter
A bson Document
representing the match criteria.
update
A bson Document
representing the update to be applied to a matching document.
upsert
When true, creates a new document if no document matches the query.
Return ValueA publisher that eventually return UpdateResult
or Error
.
Updates a single document matching the provided filter in this collection.
Parameters filter
A bson Document
representing the match criteria.
update
A bson Document
representing the update to be applied to a matching document.
A publisher that eventually return UpdateResult
or Error
.
Updates multiple documents matching the provided filter in this collection.
Parameters filter
A bson Document
representing the match criteria.
update
A bson Document
representing the update to be applied to a matching document.
upsert
When true, creates a new document if no document matches the query.
Return ValueA publisher that eventually return UpdateResult
or Error
.
Updates multiple documents matching the provided filter in this collection.
Parameters filter
A bson Document
representing the match criteria.
update
A bson Document
representing the update to be applied to a matching document.
A publisher that eventually return UpdateResult
or Error
.
Updates a single document in a collection based on a query filter and returns the document in either its pre-update or post-update form. Unlike updateOneDocument
, this action allows you to atomically find, update, and return a document with the same command. This avoids the risk of other update operations changing the document between separate find and update operations.
filter
A bson Document
representing the match criteria.
update
A bson Document
representing the update to be applied to a matching document.
options
RemoteFindOneAndModifyOptions
to use when executing the command.
A publisher that eventually return Document
or nil
if document wasn’t found or Error
.
Updates a single document in a collection based on a query filter and returns the document in either its pre-update or post-update form. Unlike updateOneDocument
, this action allows you to atomically find, update, and return a document with the same command. This avoids the risk of other update operations changing the document between separate find and update operations.
filter
A bson Document
representing the match criteria.
update
A bson Document
representing the update to be applied to a matching document.
A publisher that eventually return Document
or nil
if document wasn’t found or Error
.
Overwrites a single document in a collection based on a query filter and returns the document in either its pre-replacement or post-replacement form. Unlike updateOneDocument
, this action allows you to atomically find, replace, and return a document with the same command. This avoids the risk of other update operations changing the document between separate find and update operations.
A publisher that eventually return Document
or nil
if document wasn’t found or Error
.
Overwrites a single document in a collection based on a query filter and returns the document in either its pre-replacement or post-replacement form. Unlike updateOneDocument
, this action allows you to atomically find, replace, and return a document with the same command. This avoids the risk of other update operations changing the document between separate find and update operations.
filter
A Document
that should match the query.
replacement
A Document
describing the replacement.
A publisher that eventually return Document
or nil
if document wasn’t found or Error
.
Removes a single document from a collection based on a query filter and returns a document with the same form as the document immediately before it was deleted. Unlike deleteOneDocument
, this action allows you to atomically find and delete a document with the same command. This avoids the risk of other update operations changing the document between separate find and delete operations.
A publisher that eventually return Document
or nil
if document wasn’t found or Error
.
Removes a single document from a collection based on a query filter and returns a document with the same form as the document immediately before it was deleted. Unlike deleteOneDocument
, this action allows you to atomically find and delete a document with the same command. This avoids the risk of other update operations changing the document between separate find and delete operations.
filter
A Document
that should match the query.
A publisher that eventually return Document
or nil
if document wasn’t found or Error
.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4