Here is my test code:
func updateUserCustomData() {
app.login(credentials: Credentials.jwt(token: CredentialToken.jwtToken)) { (result) in
switch result {
case .failure(let error):
print("Failed to log in: \(error.localizedDescription)")
case .success(let user):
// Access the custom user document remotely to update it.
// need to make these constants
let client = user.mongoClient("mongodb-atlas")
let database = client.database(named: "AltoProDev0")
let collection = database.collection(withName: "User")
collection.updateOneDocument(
filter: ["userId": AnyBSON(user.id)],
update: ["firstName": "cerulean",
"lastName": "last",
"title": "boss",
"phone": "8888888888"
]
) { (result) in
switch result {
case .failure(let error):
//*** James fails here
print("Failed to update: \(error.localizedDescription)")
return
case .success(let updateResult):
// User document updated.
print("Matched: \(updateResult.matchedCount), updated: \(updateResult.modifiedCount)")
self.getUserCustomData()
}
}
}
}
}
The id’s are all correct but it always gives me a successful result of:
Matched: 0, updated: 0
Why?