Rename field in mongoose

First, you'll need to add name to your schema so it becomes:

const user = new Schema({
    name: { type:String },
    firstname: { type:String }, //keep this for now
    lastname: { type:String },
    username: { type:String },
    password: { type:String },
    user_type: { type:String },
});

Now, in your app code somewhere, you'll need to run this:

User.updateMany({}, { $rename: { firstname: 'name' } }, { multi: true }, function(err, blocks) {
    if(err) { throw err; }
    console.log('done!');
});

Now, you can remove firstname from your schema if you wish.