MongoDB's ObjectId relationship in Schema doesn't work after server restart

I created a simple mongo schema in NodeJs using the mongoose package.

var ProjectSchema = new Schema({
    name: String,
    author: {type: Schema.ObjectId, ref: 'User'},
    description: String,
    date: { type: Date, default: Date.now }
};

And when I want to test whether the author of the post is the current user, if the project was created on the current server session (aka without restarting) it will work. But if I restart the server the Object Id's are not equal.

How can I fix this?

Thanks!

Keep the type of author as String. Once you fetch the current user's data from session, you can perform

user._id.toString() 

to get the string representation of objectID where I user is the dbObject. You can then look this id up in the ProjectSchema collection for any author match