mongoose-version icon indicating copy to clipboard operation
mongoose-version copied to clipboard

Run Error

Open hydrotik opened this issue 12 years ago • 15 comments

/pathtoproject/myproject/node_modules/mongoose-version/node_modules/mongoose/lib/schema/array.js:50 this.caster = new caster(null, castOptions); ^ TypeError: object is not a function at new SchemaArray (/pathtoproject/myproject/node_modules/mongoose-version/node_modules/mongoose/lib/schema/array.js:50:19) at Function.Schema.interpretAsType (/pathtoproject/myproject/node_modules/mongoose-version/node_modules/mongoose/lib/schema.js:338:12) at Schema.path (/pathtoproject/myproject/node_modules/mongoose-version/node_modules/mongoose/lib/schema.js:293:29) at Schema.add (/pathtoproject/myproject/node_modules/mongoose-version/node_modules/mongoose/lib/schema.js:208:12) at new Schema (/pathtoproject/myproject/node_modules/mongoose-version/node_modules/mongoose/lib/schema.js:70:10) at Object.module.exports as array at module.exports (/pathtoproject/myproject/node_modules/mongoose-version/lib/version.js:22:33) at Schema.plugin (/pathtoproject/myproject/node_modules/mongoose/lib/schema.js:545:3) at module.exports (/pathtoproject/myproject/modules/cms/models/project.js:102:19) at /pathtoproject/myproject/modules/cms/models/index.js:50:29

Using Mongoose 3.6.15

hydrotik avatar Jul 18 '13 04:07 hydrotik

This bug should be closed here. It's not a bug in "mongoose-version", but rather it Mongoose giving a poor diagnostic function. Instead of telling you where the problem is in your own schema declaration, it's telling you exactly the point in its own code where it fell over.

Consider re-filing the bug against Mongoose, with a clear title, a description of what you expected to happen, what actually happen, and any steps to reproduce.

markstos avatar Nov 04 '13 16:11 markstos

I get the same error trying to use versions with SchemaName.plugin(version); - Object is not a Function

funkytek avatar Nov 24 '13 11:11 funkytek

no mather what schema, i'm getting same error

mauron85 avatar Feb 14 '14 11:02 mauron85

@funkytek, @mauron85 See my comment above. File your issue with Mongoose instead.

markstos avatar Feb 14 '14 13:02 markstos

@markstos i don't get it. I used empty schema declaration like this:

 var userSchema = new mongoose.Schema({});

and still get same error. I suppose that empty schema is 100% valid.

mauron85 avatar Feb 14 '14 16:02 mauron85

@mauron85 then that's definitely an issue with Mongoose, not this project. File a bug there.

markstos avatar Feb 14 '14 16:02 markstos

Ok, but I forgot to mention that the error occurs only when using mongoose-version plugin.

mauron85 avatar Feb 14 '14 16:02 mauron85

OH. That sounds like a Mongoose-version issue then. and it's a nice simple test case: --- just load an mongoose-version, create an empty schema, and some poor diagnostic message is returned.

Any mongoose-version devs listening here?

markstos avatar Feb 14 '14 16:02 markstos

Dev is listening but currently too drunk to fix it. On Feb 14, 2014 5:33 PM, "Mark Stosberg" [email protected] wrote:

OH. That sounds like a Mongoose-version issue then. and it's a nice simple test case: --- just load an mongoose-version, create an empty schema, and some poor diagnostic message is returned.

Any mongoose-version devs listening here?

Reply to this email directly or view it on GitHubhttps://github.com/saintedlama/mongoose-version/issues/6#issuecomment-35099774 .

saintedlama avatar Feb 14 '14 21:02 saintedlama

Just pushed the test 'should allow to create an empty versioned model' in test\issues to reproduce this bug. No luck, tests are green like :green_apple:. Can you try to execute the test in your environment? Mongoose version used is 3.6.2

saintedlama avatar Feb 21 '14 14:02 saintedlama

Hi I just upgraded to version 0.2.4 (from 0.2.3) and I don't get the startup error anymore. I can even use monoose 3.8.x

The only minor issue is that I can use validate parameter in schema like:

var deliverySchema = new mongoose.Schema({
    trackingNr: {
        type: String,
        validate: /\S+/,
...

because I get regex error:

/private/var/www/mapilary-api/node_modules/mongoose/lib/schematype.js:620
      validate(validator.test(value), message, type, value);
                         ^
TypeError: Method RegExp.prototype.test called on incompatible receiver object
    at RegExp.test (native)
    at /private/var/www/mapilary-api/node_modules/mongoose/lib/schematype.js:620:26
    at Array.forEach (native)
    at SchemaString.SchemaType.doValidate (/private/var/www/mapilary-api/node_modules/mongoose/lib/schematype.js:614:19)
    at /private/var/www/mapilary-api/node_modules/mongoose/lib/document.js:956:9
    at process._tickDomainCallback (node.js:459:13)
    at process._tickFromSpinner (node.js:390:15)

Anyway, thank you for your support.

mauron85 avatar Feb 21 '14 22:02 mauron85

I get the same error with caster. As soon as I use the plugin on an existing project it bugs out (and I'm using same version of owl-deepcopy and mongoose as the tests). I've tried wiping DB as well.

niftylettuce avatar Jun 02 '14 22:06 niftylettuce

Yes I am getting the caster error as well. It seems to be caused whenever I use the mixed type data: {type: [[Schema.Types.Mixed]]},.

    this.caster = new caster(null, castOptions);
                  ^

TypeError: caster is not a function

avdaredevil avatar Feb 04 '16 19:02 avdaredevil

Seeing the same thing caused by: , versions : [clonedSchema]

David-Mulder avatar Feb 18 '16 15:02 David-Mulder

@david-mulder try versions: [clonedSchema.schema]

avdaredevil avatar Feb 18 '16 15:02 avdaredevil