Can't seem to update customUserData

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?

More info: it does see the role?

 {
  "arguments": [
    {
      "database": "AltoProDev0",
      "collection": "User",
      "query": {
        "userId": "610402f726071024d7cf3152"
      },
      "update": {
        "title": "boss",
        "lastName": "last",
        "firstName": "cerulean",
        "phone": "8888888888"
      },
      "upsert": false
    }
  ],
  "name": "updateOne",
  "service": "mongodb-atlas"
}
Function Call Location:
US-VA
Compute Used:
47601513 bytes•ms
Remote IP Address:
64.4.122.150
SDK:
Realm Cocoa v10.11.0
Platform Version:
Version 15.0 (Build 19A5297e)
Rule Performance Metrics:
{
  "AltoProDev0.User": {
    "no_matching_role": 0
  }
}

In my REAL Scheme Rules I have :slight_smile:

{
  "User._id": "%%user.id"
}

// SCHEME:

{
  "properties": {
    "_id": {
      "bsonType": "string"
    },
    "_partition": {
      "bsonType": "string"
    },
    "memberOf": {
      "bsonType": "array",
      "items": {
        "bsonType": "object",
        "properties": {
          "name": {
            "bsonType": "string"
          },
          "partition": {
            "bsonType": "string"
          },
          "_partition": {
            "bsonType": "string"
          },
          "date": {
            "bsonType": "date"
          },
          "notes": {
            "bsonType": "string"
          },
          "hourlyRate": {
            "bsonType": "decimal"
          },
          "order": {
            "bsonType": "long"
          },
          "unbilledtotal": {
            "bsonType": "decimal"
          }
        },
        "title": "Project",
        "required": [
          "_partition",
          "hourlyRate",
          "order",
          "unbilledtotal"
        ]
      }
    },
    "name": {
      "bsonType": "string"
    },
    "companyId": {
      "bsonType": "objectId"
    },
    "memberOfProject": {
      "bsonType": "array",
      "items": {
        "title": "Project",
        "bsonType": "object",
        "required": [
          "_partition",
          "hourlyRate",
          "order",
          "unbilledtotal"
        ],
        "properties": {
          "name": {
            "bsonType": "string"
          },
          "partition": {
            "bsonType": "string"
          },
          "_partition": {
            "bsonType": "string"
          },
          "date": {
            "bsonType": "date"
          },
          "notes": {
            "bsonType": "string"
          },
          "hourlyRate": {
            "bsonType": "decimal"
          },
          "order": {
            "bsonType": "long"
          },
          "unbilledtotal": {
            "bsonType": "decimal"
          }
        }
      }
    },
    "firstName": {
      "bsonType": "string"
    },
    "lastName": {
      "bsonType": "string"
    },
    "title": {
      "bsonType": "string"
    },
    "phone": {
      "bsonType": "string"
    }
  },
  "required": [
    "_id",
    "_partition",
    "name"
  ],
  "title": "User"
}

What am I missing?

Are you asking me a question or helping with my answer. I am a bit confused?

LOL :smiley: is been lonely here.

I starting having same logs output after updating a user doc, have no idea what is triggered by.

As soon I update that specific file, cannot log in.