Like the title says, it crashes when using recursive schemas.
The following code produces the error below.
Code:
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test', { useMongoClient: true });
mongoose.Promise = require('bluebird');
var idValidator = require('mongoose-id-validator');
var Tasks = new mongoose.Schema();
Tasks.add({
title : String
, subtasks : [Tasks]
});
Tasks.plugin(idValidator);
Error:
c:\(...)\test\node_modules\mongoose-id-validator\lib\id-validator.js:33
schema.eachPath(function (path, schemaType) {
^
RangeError: Maximum call stack size exceeded
at c:\(...)\test\node_modules\mongoose-id-validator\lib\id-validator.js:33:30
at Schema.eachPath (c:\(...)\test\node_modules\mongoose\lib\schema.js:673:5)
at IdValidator.validateSchema (c:\(...)\test\node_modules\mongoose-id-validator\lib\id-validator.js:33:12)
at c:\(...)\node_modules\mongoose-id-validator\lib\id-validator.js:37:27
(last 3 lines repeated 4 more times)
Like the title says, it crashes when using recursive schemas. The following code produces the error below.
Code:
Error:
Great plugin anyway.