mongoose self reference with own ObjectId throwing: cast to ObjectId failed

I am using nodejs, mongoose and I trying to build a shema that contains a reference to itself via parent. Parent should be a reference to DataType.

var DataTypeSchema = new Schema({
    _id: String,
    label: { type: String, required: true },
    comment: { type: String },
    url: { type: String, required: true },
    parent: { type: Schema.Types.ObjectId, ref: 'DataType' },
    values: []
});

var DataType = mongoose.model('DataType', DataTypeSchema);
module.exports.DataType = DataType;

Every DataType has own ID(not generated by mongo) and I think this is a place where it causes problems. It throws me an error cast to objectid failed for value "Number" at path "parent", where Number is object with ID "Number" already saved in DB.

Thanks

The type of the parent reference must match the type of the _id in the model it references. So instead of Schema.Types.ObjectId it should be String:

...
parent: { type: String, ref: 'DataType' },