鉴于此Category架构
{
title: String,
parent: {
type: Schema.Types.ObjectId,
ref: 'Category',
required: true
}
}
现在,如果Category我parent有_id一个parent.
有没有更好的方法来做到这一点:?
var parentID = (category.parent._id || category.parent).toString();