Skip to content

Commit 57c9486

Browse files
authored
New initialization/cleanup instructions
1 parent cbfa185 commit 57c9486

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

README.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The official [MongoDB](https://www.mongodb.com/) driver for Swift.
88
- [Documentation](#documentation)
99
- [Bugs/Feature Requests](#bugs--feature-requests)
1010
- [Installation](#installation)
11-
- [macOS and Linux](#os-x-and-linux)
11+
- [macOS and Linux](#macos-and-linux)
1212
- [Step 1: Install the MongoDB C Driver](#step-1-install-the-mongodb-c-driver)
1313
- [Step 2: Install MongoSwift](#step-2-install-mongoswift)
1414
- [iOS, tvOS, and watchOS](#ios-tvos-and-watchos)
@@ -96,26 +96,18 @@ Then run `pod install` to install your project's dependencies.
9696

9797
## Example Usage
9898

99-
### Initialization
100-
You *must* call `MongoSwift.initialize()` once at the start of your application to
101-
initialize `libmongoc`. This initializes global state, such as process counters. Subsequent calls will have no effect.
102-
103-
You should call `MongoSwift.cleanup()` exactly once at the end of your application to release all memory and other resources allocated by `libmongoc`. `MongoSwift.initialize()`
104-
will *not* reinitialize the driver after `MongoSwift.cleanup()`.
99+
Note: You should call `cleanupMongoSwift()` exactly once at the end of your application to release all memory and other resources allocated by `libmongoc`.
105100

106101
### Connect to MongoDB and Create a Collection
107102
```swift
108103
import MongoSwift
109104

110-
// initialize global state
111-
MongoSwift.initialize()
112-
113105
let client = try MongoClient("mongodb://localhost:27017")
114106
let db = client.db("myDB")
115107
let collection = try db.createCollection("myCollection")
116108

117109
// free all resources
118-
MongoSwift.cleanup()
110+
cleanupMongoSwift()
119111
```
120112

121113
Note: we have included the client `connectionString` parameter for clarity, but if connecting to the default `"mongodb://localhost:27017"`it may be omitted: `let client = try MongoClient()`.

0 commit comments

Comments
 (0)