Credentials object with new user

I would like to create a credentials object that is tied to a user object in the database. in such that the models are laid out like so

const UserSchema = mongoose.Schema({
    (... some other details like name, profile information),
    credentials: {
        type: mongoose.Schema.Types.ObjectId,
        required: true,
        ref: "credential"
    },
    ...
})

The problem is the credentials object needs to be instantiated at the same time as the new User object, the biggest hurdle i am facing is getting these two objects to know about each others existence, and building a relationship between them. if i were creating the object credential/user later in the code and then referencing it later, this would work, but upon account creation in the code, i cant create a new user and a new credentials object at the same time to fix this problem…

if anyone has any tips on how to make this happen, id greatly appreciate the advice